pm2 / cron worker to send reminder

This commit is contained in:
lesion
2019-03-10 01:01:23 +01:00
parent e41de7208c
commit 6ed639d94b
39 changed files with 264 additions and 105 deletions

View File

@@ -1,3 +1,3 @@
module.exports = {
"extends": "standard"
};
'extends': 'standard'
}

View File

@@ -37,7 +37,7 @@
v-icon(name='calendar')
span.ml-1 {{$t('Events')}}
p {{$t('event_confirm_explanation')}}
el-table(:data='paginatedEvents' small primary-key='id')
el-table(:data='paginatedEvents' small primary-key='id' v-loading='loading')
el-table-column(:label='$t("Name")')
template(slot-scope='data') {{data.row.title}}
el-table-column(:label='$t("Where")')
@@ -76,6 +76,7 @@
<script>
import { mapState } from 'vuex'
import api from '@/api'
import { Message } from 'element-ui'
export default {
name: 'Admin',
@@ -94,6 +95,7 @@ export default {
place: {name: '', address: '' },
tag: {name: '', color: ''},
events: [],
loading: false
}
},
async mounted () {
@@ -147,8 +149,10 @@ export default {
async confirm (id) {
console.log('dentro confirm', id)
try {
this.loading = true
await api.confirmEvent(id)
this.$message({
this.loading = false
Message({
message: this.$t('event_confirmed'),
type: 'success'
})

View File

@@ -1,5 +1,7 @@
<template lang="pug">
v-calendar#calendar.card(
show-caps
:popover-expanded='true'
:attributes='attributes'
:from-page.sync='page'
is-expanded is-inline)
@@ -22,8 +24,8 @@ export default {
page: { month, year},
}
},
mounted () {
this.updateEvents(this.page)
async mounted () {
await this.updateEvents(this.page)
},
watch: {
page () {

View File

@@ -1,5 +1,5 @@
<template lang="pug">
b-card(bg-variant='dark' text-variant='white'
b-card(bg-variant='dark' text-variant='white' :class="{ withImg: event.image_path ? true : false }"
@click='$router.push("/event/" + event.id)'
:img-src='imgPath')
strong {{event.title}}
@@ -58,7 +58,8 @@ export default {
}
.card-img {
max-height: 180px;
height: 180px;
object-fit: cover;
}

View File

@@ -74,7 +74,7 @@ export default {
async remove () {
await api.delEvent(this.event.id)
this.delEvent(this.event.id)
this.$refs.modal.hide()
this.$refs.eventDetail.hide()
}
}
}

View File

@@ -12,11 +12,11 @@
el-tab-pane.pt-1(label='email' name='email')
p(v-html='$t(`export_email_explanation`)')
b-form
el-switch(v-model='reminder.send_on_insert' :active-text="$t('notify_on_insert')")
el-switch(v-model='reminder.notify_on_add' :active-text="$t('notify_on_insert')")
br
el-switch.mt-2(v-model='reminder.send_reminder' :active-text="$t('send_reminder')")
el-input.mt-2(v-model='reminder.mail' :placeholder="$t('Insert your address')")
el-button.mt-2.float-right(type='success' @click='activate_email') {{$t('Send')}}
//- el-switch.mt-2(v-model='reminder.send_reminder' :active-text="$t('send_reminder')")
el-input.mt-2(v-model='reminder.email' :placeholder="$t('Insert your address')")
el-button.mt-2.float-right(type='success' @click='add_reminder') {{$t('Send')}}
el-tab-pane.pt-1(label='feed rss' name='feed')
span(v-html='$t(`export_feed_explanation`)')
@@ -30,7 +30,7 @@
el-tab-pane.pt-1(label='list' name='list')
p(v-html='$t(`export_list_explanation`)')
b-card.mb-1(no-body header='Eventi')
el-card.mb-1(no-body header='Eventi')
b-list-group#list(flush)
b-list-group-item.flex-column.align-items-start(v-for="event in filteredEvents" :key='event.id'
:to='`/event/${event.id}`')
@@ -40,7 +40,7 @@
strong.mb-1 {{event.title}}
br
small.float-right {{event.place.name}}
el-tag.mr-1(:color='tag.color' size='mini' v-for='tag in event.tags' :key='tag.tag') {{tag.tag}}
el-tag.mr-1(:color='tag.color || "grey"' size='mini' v-for='tag in event.tags' :key='tag.tag') {{tag.tag}}
el-input.mb-1(type='textarea' v-model='script')
el-button.float-right(plain type="primary" icon='el-icon-document' v-clipboard:copy="script") Copy
@@ -58,6 +58,7 @@ import path from 'path'
import filters from '../filters'
import Calendar from '@/components/Calendar'
import {intersection} from 'lodash'
import api from '@/api'
export default {
name: 'Export',
@@ -66,7 +67,7 @@ export default {
return {
type: 'email',
link: '',
reminder: { send_on_insert: true, send_reminder: false },
reminder: { notify_on_add: true, send_reminder: false },
export_list: true,
script: `<iframe>Ti piacerebbe</iframe>`,
}
@@ -81,7 +82,8 @@ export default {
}
},
methods: {
activate_email () {
async add_reminder () {
await api.emailReminder({ ...this.reminder, filters: this.filters})
this.$refs.modal.hide()
},
loadLink () {

View File

@@ -1,9 +1,10 @@
<template lang="pug">
magic-grid(animate :gap=5 :maxCols=4 :maxColWidth='300')
magic-grid(:animate="false" useMin :gap=5 :maxCols=4
:maxColWidth='400' ref='magicgrid')
div.mt-1.item
Search#search
Calendar
Event.item(v-for='event in filteredEvents'
Event.item.mt-1(v-for='event in filteredEvents'
:key='event.id'
:event='event')
</template>
@@ -20,10 +21,17 @@ import Search from '@/components/Search'
export default {
name: 'Home',
components: { Event, Calendar, Search },
watch: {
filteredEvents () {
this.$nextTick( this.$refs.magicgrid.positionItems)
}
},
computed: {
...mapState(['events', 'filters']),
filteredEvents () {
return this.$store.getters.filteredEvents.filter(e => !e.past)
return this.$store.getters.filteredEvents
.filter(e => !e.past)
.sort((a, b) => { a.start_datetime > b.start_datetime})
}
}
}
@@ -35,8 +43,11 @@ export default {
}
.item {
/* min-width: 350px; */
width: 100%;
max-width: 400px;
margin-top: 4px;
position: absolute;
cursor: pointer;
}
.card-columns {

View File

@@ -1,8 +1,8 @@
<template lang='pug'>
b-modal(@show="$refs.email.focus()" :title='$t("Login")' hide-footer
b-modal(@shown="$refs.email.focus()" :title='$t("Login")' hide-footer
@hidden='$router.replace("/")' :visible='true')
el-form
span {{$t('login_explanation')}}
p {{$t('login_explanation')}}
el-input.mb-2(v-model='email' type='email' :placeholder='$t("Email")' autocomplete='email' ref='email')
v-icon(name='user' slot='prepend')
el-input.mb-2(v-model='password' type='password' :placeholder='$t("Password")')

View File

@@ -1,33 +1,27 @@
<template lang='pug'>
b-modal(hide-footer
@hidden='$router.replace("/")' :title="$t('Register')" :visible='true' @shown='$refs.email.focus()')
b-form
p.text-muted(v-html="$t('register_explanation')")
b-input-group.mb-1
b-input-group-prepend
b-input-group-text @
b-form-input(ref='email' v-model='user.email' type="text" class="form-control" placeholder="Email" autocomplete="email" )
b-modal(hide-footer @hidden='$router.replace("/")'
:title="$t('Register')" :visible='true' @shown='$refs.email.focus()')
el-form
p(v-html="$t('register_explanation')")
el-input.mb-2(ref='email' v-model='user.email' type='email'
:placeholder='$t("Email")' autocomplete='email')
span(slot='prepend') @
el-input.mb-2(v-model='user.password' type="password" placeholder="Password")
v-icon(name='lock' slot='prepend')
b-input-group.mb-1
b-input-group-prepend
b-input-group-text
v-icon(name='lock')
b-form-input(v-model='user.password' type="password" class="form-control" placeholder="Password")
b-input-group.mb-1
b-input-group-prepend
b-input-group-text
v-icon(name='envelope-open-text')
b-form-textarea(v-model='user.description' type="text" rows='3' class="form-control" :placeholder="$t('Description')")
el-input.mb-2(v-model='user.description' type="textarea" rows='3' :placeholder="$t('Description')")
v-icon(name='envelope-open-text')
b-button.float-right(variant="success" @click='register') {{$t('Send')}}
el-button.float-right(plain type="success" icon='el-icon-arrow-right' @click='register') {{$t('Send')}}
</template>
<script>
import api from '@/api'
import { mapActions } from 'vuex';
import { Message } from 'element-ui'
export default {
name: 'Register',
data () {
@@ -42,7 +36,7 @@ export default {
try {
const user = await api.register(this.user)
this.$router.go(-1)
this.$message({
Message({
message: this.$t('registration_complete'),
type: 'success'
})

View File

@@ -2,7 +2,7 @@
b-modal(ref='modal' @hidden='$router.replace("/")' size='md' :visible='true'
:title="edit?$t('Edit event'):$t('New event')" hide-footer)
b-container
el-tabs.mb-2(v-model='activeTab' v-loading='sending')
el-tabs.mb-2(v-model='activeTab' v-loading='sending' @tab-click.native='changeTab')
el-tab-pane
span(slot='label') {{$t('Where')}} <v-icon name='map-marker-alt'/>
@@ -34,7 +34,7 @@
el-tab-pane
span(slot='label') {{$t('What')}} <v-icon name='file-alt'/>
span {{$t('what_explanation')}}
el-input.mb-3(v-model='event.title')
el-input.mb-3(v-model='event.title' ref='title')
span {{$t('description_explanation')}}
el-input.mb-3(v-model='event.description' type='textarea' :rows='3')
span {{$t('tag_explanation')}}
@@ -44,7 +44,7 @@
el-option(v-for='tag in tags' :key='tag.tag'
:label='tag' :value='tag')
el-button.float-right(@click='next' :disabled='!couldProceed') {{$t('Next')}}
el-button.float-right(@click.native='next' :disabled='!couldProceed') {{$t('Next')}}
el-tab-pane
span(slot='label') {{$t('Media')}} <v-icon name='image'/>
@@ -132,14 +132,19 @@ export default {
},
methods: {
...mapActions(['addEvent', 'updateEvent', 'updateMeta']),
changeTab (tab) {
if (this.activeTab === "2") this.$refs.title.focus()
},
next () {
this.activeTab = String(Number(this.activeTab)+1)
if (this.activeTab === "2") {
this.$refs.title.focus()
}
},
prev () {
this.activeTab = String(Number(this.activeTab-1))
},
placeChoosed () {
console.log('dentro placeChoosed')
const place = this.places.find( p => p.name === this.event.place.name )
if (place && place.address) {
this.event.place.address = place.address
@@ -186,6 +191,7 @@ export default {
await this.updateEvent(formData)
} else {
await this.addEvent(formData)
// this.$router.push('/')
}
this.updateMeta()
this.sending = false

View File

@@ -77,7 +77,7 @@ const it = {
'Insert your address': 'Inserisci il tuo indirizzo',
registration_complete: 'Controlla la tua posta (anche la cartella spam)',
registration_email: `Ciao, la tua registrazione sarà confermata nei prossimi giorni. Riceverai una conferma non temere.`,
register_explanation: `I movimenti hanno bisogno di organizzarsi e autofinanziarsi. <br/>Questo è un dono per voi, non possiamo più vedervi usare le piattaforme del capitalismo. Solo eventi non commerciali e ovviamente antifascisti, antisessisti, antirazzisti.
register_explanation: `I movimenti hanno bisogno di organizzarsi e autofinanziarsi. <br/>Questo è un dono per voi, usatelo solo per eventi non commerciali e ovviamente antifascisti, antisessisti, antirazzisti.
<br/>Prima di poter pubblicare <strong>dobbiamo approvare l'account</strong>, considera che <strong>dietro questo sito ci sono delle persone</strong> di
carne e sangue, scrivici quindi due righe per farci capire che eventi vorresti pubblicare.`,
'Not registered?': `Non sei registrata?`,

View File

@@ -4,6 +4,7 @@ import BootstrapVue from 'bootstrap-vue'
import VCalendar from 'v-calendar'
import 'vue-awesome/icons/lock'
import 'vue-awesome/icons/user'
import 'vue-awesome/icons/plus'
import 'vue-awesome/icons/cog'
import 'vue-awesome/icons/tools'
@@ -17,6 +18,7 @@ import 'vue-awesome/icons/tag'
import 'vue-awesome/icons/users'
import 'vue-awesome/icons/calendar'
import 'vue-awesome/icons/edit'
import 'vue-awesome/icons/envelope-open-text'
import Icon from 'vue-awesome/components/Icon'
@@ -26,7 +28,7 @@ import 'v-calendar/lib/v-calendar.min.css'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import { Button, Select, Tag, Option, Table, FormItem,
import { Button, Select, Tag, Option, Table, FormItem, Card,
Form, Tabs, TabPane, Switch, Input, Loading, TimeSelect,
TableColumn, ColorPicker, Pagination } from 'element-ui'
import ElementLocale from 'element-ui/lib/locale'
@@ -47,6 +49,7 @@ import itLocale from '@/locale/it'
import enLocale from '@/locale/en'
Vue.use(Button)
Vue.use(Card)
Vue.use(Select)
Vue.use(Tag)
Vue.use(Input)

View File

@@ -48,8 +48,7 @@ export default new Vuex.Store({
//
filters: {
tags: [],
places: [],
hidePast: false
places: []
}
},
mutations: {