refactoring email notification, closes #8

This commit is contained in:
les
2019-09-06 11:58:11 +02:00
parent 2c24591621
commit beebca7ab9
31 changed files with 195 additions and 149 deletions

View File

@@ -90,7 +90,7 @@
el-time-select(v-model='time.end'
:picker-options="{start: '00:00', step: '00:30', end: '24:00'}")
List(v-if='event.type==="normal"' :events='todayEvents' :title='$t("event.same_day")')
List(v-if='event.type==="normal" && todayEvents.length' :events='todayEvents' :title='$t("event.same_day")')
el-button.float-right(@click='next' type='succes' :disabled='!couldProceed') {{$t('common.next')}}
//- MEDIA / FLYER / POSTER
@@ -193,14 +193,14 @@ export default {
data.event.place.name = event.place.name
data.event.place.address = event.place.address || ''
if (event.multidate) {
data.date = { start: new Date(event.start_datetime*1000), end: new Date(event.end_datetime*1000) }
data.date = { start: moment.unix(event.start_datetime), end: moment.unix(event.end_datetime) }
data.event.type = 'multidate'
} else if (event.recurrent ) {
data.event.type = 'recurrent'
data.event.recurrent = JSON.parse(event.recurrent)
} else {
data.event.type = 'normal'
data.date = new Date(event.start_datetime*1000)
data.date = moment.unix(event.start_datetime)
}
data.time.start = moment.unix(event.start_datetime).format('HH:mm')
@@ -251,19 +251,19 @@ export default {
const date_end = moment(this.date.end)
return this.events.filter(e =>
!e.multidate ?
date_start.isSame(e.start_datetime, 'day') ||
date_start.isBefore(e.start_datime) && date_end.isAfter(e.start_datetime) :
date_start.isSame(e.start_datetime, 'day') || date_start.isSame(e.end_datetime) ||
date_start.isAfter(e.start_datetime) && date_start.isBefore(e.end_datetime))
date_start.isSame(moment.unix(e.start_datetime), 'day') ||
date_start.isBefore(moment.unix(e.start_datime)) && date_end.isAfter(moment.unix(e.start_datetime)) :
date_start.isSame(moment.unix(e.start_datetime), 'day') || date_start.isSame(moment.unix(e.end_datetime)) ||
date_start.isAfter(moment.unix(e.start_datetime)) && date_start.isBefore(moment.unix(e.end_datetime)))
} else if (this.event.type === 'recurrent' ) {
} else {
const date = moment(this.date)
return this.events.filter(e =>
!e.multidate ?
!e.recurrent && date.isSame(moment(e.start_datetime), 'day') :
moment(e.start_datetime).isSame(date, 'day') ||
moment(e.start_datetime).isBefore(date) && moment(e.end_datetime).isAfter(date)
!e.recurrent && date.isSame(moment.unix(e.start_datetime), 'day') :
moment.unix(e.start_datetime).isSame(date, 'day') ||
moment.unix(e.start_datetime).isBefore(date) && moment.unix(e.end_datetime).isAfter(date)
)
}
},
@@ -273,13 +273,13 @@ export default {
attributes.push ({ key: 'today', dates: new Date(), highlight: { color: 'yellow' }})
attributes = attributes.concat(this.filteredEvents
.filter(e => !e.multidate)
.map(e => ({ key: e.id, dot: {}, dates: new Date(e.start_datetime)})))
.filter(e => !e.multidate && !e.recurrent)
.map(e => ({ key: e.id, dot: {}, dates: moment.unix(e.start_datetime).toDate()})))
attributes = attributes.concat(this.filteredEvents
.filter(e => e.multidate)
.filter(e => e.multidate && !e.recurrent)
.map( e => ({ key: e.id, highlight: {}, dates: {
start: new Date(e.start_datetime), end: new Date(e.end_datetime) }})))
start: moment.unix(e.start_datetime).toDate(), end: moment.unix(e.end_datetime).toDate() }})))
if (this.event.type === 'recurrent' && this.event.recurrent.frequency) {
const recurrent = {}

View File

@@ -1,7 +1,8 @@
<template lang="pug">
el-card#admin
nuxt-link.float-right(to='/')
v-icon(name='times' color='red')
el-button(circle icon='el-icon-close' type='danger' size='small' plain)
h5 {{$t('common.admin')}}
el-tabs(v-model='tab')

View File

@@ -44,7 +44,7 @@
small.float-right 🔖 {{event.likes.length}}
small.float-right.mr-3 {{event.boost.length}}<br/>
strong {{$tc('common.comments', event.comments.length)}} -
<small>{{$t('event.interact_with_me_at')}} <u>{{event.user.username}}@{{settings.baseurl|url2host}}</u></small>
<small>{{$t('event.interact_with_me_at')}} <u>{{event.user && event.user.username}}@{{settings.baseurl|url2host}}</u></small>
.card-header(v-for='comment in event.comments' :key='comment.id')
a.float-right(:href='comment.data.url')

View File

@@ -5,7 +5,7 @@
el-button(circle icon='el-icon-close' type='danger' size='small' plain)
h5 {{$t('common.register')}}
el-form(@submit.native.prevent='register' method='POST' action='/api/user/register')
el-form(@submit.native.prevent='register' method='POST' action='')
p(v-html="$t('register.description')")
el-input.mb-2(v-model='user.username' type='text' name='username'
@@ -23,7 +23,7 @@
v-icon(name='envelope-open-text')
el-button(plain type="success" native-type='submit'
:disabled='disabled') {{$t('common.send')}} <v-icon name='chevron-right'/>
:disabled='disabled') {{$t('common.send')}} <v-icon :name='loading?"circle-notch":"chevron-right"' :spin='loading'/>
</template>
<script>
@@ -35,8 +35,8 @@ export default {
name: 'Register',
data () {
return {
error: {},
user: { }
loading: false,
user: {}
}
},
head () {
@@ -57,6 +57,7 @@ export default {
methods: {
...mapActions(['login']),
async register () {
this.loading = true
try {
const { user } = await this.$axios.$post('/user/register', this.user)
Message({
@@ -73,6 +74,7 @@ export default {
type: 'error'
})
}
this.loading = false
}
}
}

View File

@@ -3,53 +3,27 @@
nuxt-link.float-right(to='/')
el-button(circle icon='el-icon-close' type='danger' size='small' plain)
h5 <img src='/favicon.ico'/> {{$t('common.activate_user')}}
div(v-if='valid')
el-form
el-form-item {{$t('common.password')}}
el-input(type='password', v-model='new_password')
el-button(plain type="success" icon='el-icon-send', @click='change_password') {{$t('common.send')}}
div(v-else) {{$t('recover.not_valid_code')}}
h5 <img src='/favicon.ico'/> {{$t('confirm.title')}}
p(v-if='valid' v-html='$t("confirm.valid")')
p(v-else) {{$t('confirm.not_valid')}}
</template>
<script>
import { Message } from 'element-ui'
export default {
name: 'Recover',
name: 'Confirm',
data () {
return { new_password: '' }
return { valid: true }
},
async asyncData({ params, $axios }) {
const code = params.code
const recover_code = params.code
try {
const valid = await $axios.$post('/user/check_recover_code', { recover_code: code })
return { valid, code }
}
catch (e) {
const valid = await $axios.$post('/user/check_recover_code', { recover_code })
return { valid }
} catch (e) {
return { valid: false }
}
},
methods: {
async change_password () {
try {
const res = await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
Message({
showClose: true,
type: 'success',
message: this.$t('common.password_updated')
})
this.$router.replace('/login')
} catch(e) {
Message({
showClose: true,
type: 'warning',
message: e
})
}
}
}
}
</script>