This commit is contained in:
lesion
2019-03-20 01:52:48 +01:00
parent f44a78c4e9
commit 3fe3a478b7
10 changed files with 29 additions and 21 deletions

View File

@@ -28,6 +28,11 @@ const eventController = {
function match (event, filters) { function match (event, filters) {
// matches if no filter specified // matches if no filter specified
if (!filters) return true if (!filters) return true
// check for visibility
if (filters.is_visible && filters.is_visible !== event.is_visible) return false
if (!filters.tags && !filters.places) return true
if (!filters.tags.length && !filters.places.length) return true if (!filters.tags.length && !filters.places.length) return true
if (filters.tags.length) { if (filters.tags.length) {
const m = lodash.intersection(event.tags.map(t => t.tag), filters.tags) const m = lodash.intersection(event.tags.map(t => t.tag), filters.tags)
@@ -70,12 +75,11 @@ const eventController = {
const id = req.params.event_id const id = req.params.event_id
const event = await Event.findByPk(id) const event = await Event.findByPk(id)
// insert notification
const notifications = await eventController.getNotifications(event)
await event.setNotifications(notifications)
try { try {
await event.update({ is_visible: true }) await event.update({ is_visible: true })
// insert notification
const notifications = await eventController.getNotifications(event)
await event.setNotifications(notifications)
res.send(200) res.send(200)
} catch (e) { } catch (e) {
res.send(404) res.send(404)

View File

@@ -21,7 +21,7 @@ const exportController = {
wherePlace.name = places.split(',') wherePlace.name = places.split(',')
} }
const events = await Event.findAll({ const events = await Event.findAll({
order: [['start_datetime', 'ASC']], // order: [['start_datetime', 'ASC']],
where: { start_datetime: { [Op.gte]: yesterday } }, where: { start_datetime: { [Op.gte]: yesterday } },
include: [Comment, { include: [Comment, {
model: Tag, model: Tag,

View File

@@ -105,11 +105,10 @@ const userController = {
if (req.user) await req.user.addEvent(event) if (req.user) await req.user.addEvent(event)
event = await Event.findByPk(event.id, { include: [User, Tag, Place] }) event = await Event.findByPk(event.id, { include: [User, Tag, Place] })
if (req.user) { // insert notifications
// insert notifications const notifications = await eventController.getNotifications(event)
const notifications = await eventController.getNotifications(event) await event.setNotifications(notifications)
await event.setNotifications(notifications)
}
return res.json(event) return res.json(event)
}, },

View File

@@ -2,14 +2,17 @@ h3 #{event.title}
p Dove: #{event.place.name} - #{event.place.address} p Dove: #{event.place.name} - #{event.place.address}
p Quando: #{datetime(event.start_datetime)} p Quando: #{datetime(event.start_datetime)}
br br
<img style="width: 100%" src="#{config.apiurl}/#{event.image_path}" /> if event.image_path
<img style="width: 100%" src="#{config.apiurl}/uploads/#{event.image_path}" />
p #{event.description} p #{event.description}
each tag in event.tags
span ##{tag.tag}
br
<a href="#{config.baseurl}/event/#{event.id}">#{config.baseurl}/event/#{event.id}</a> <a href="#{config.baseurl}/event/#{event.id}">#{config.baseurl}/event/#{event.id}</a>
p #{event.tags.join(', ')}
hr hr
if to_confirm if to_confirm
p Puoi confermare questo evento <a href="#{config.apiurl}/api/event/confirm/#{event.id}">#{config.apiurl}qui</a> p Puoi confermare questo evento <a href="#{config.baseurl}/admin/confirm/#{event.id}">qui</a>
else //- else
p Puoi eliminare queste notifiche <a href="#{confir.apiurl}/api/del_notification/#{notification.remove_code}">qui</a> p Puoi eliminare queste notifiche <a href="#{confir.apiurl}/api/del_notification/#{notification.remove_code}">qui</a>
<a href="#{config.baseurl}">#{config.title} - #{config.description}</a> <a href="#{config.baseurl}">#{config.title} - #{config.description}</a>

View File

@@ -34,8 +34,8 @@ const Notification = db.define('notification', {
} }
}) })
Notification.findOrCreate({ where: { type: 'mastodon' } }) Notification.findOrCreate({ where: { type: 'mastodon', filters: { is_visible: true } } })
Notification.findOrCreate({ where: { type: 'admin_email' } }) Notification.findOrCreate({ where: { type: 'admin_email', filters: { is_visible: false } } })
const Place = db.define('place', { const Place = db.define('place', {
name: { type: Sequelize.STRING, unique: true, index: true }, name: { type: Sequelize.STRING, unique: true, index: true },

View File

@@ -144,7 +144,6 @@ export default {
}, },
methods: { methods: {
placeSelected (items) { placeSelected (items) {
console.log('dentro place selected ', items, items.length)
if (items.length === 0 ) { if (items.length === 0 ) {
this.place.name = this.place.address = '' this.place.name = this.place.address = ''
return return

View File

@@ -23,7 +23,7 @@ export default {
components: { Event, Calendar, Search }, components: { Event, Calendar, Search },
watch: { watch: {
filteredEvents () { filteredEvents () {
this.$nextTick( this.$refs.magicgrid.positionItems) this.$nextTick(this.$refs.magicgrid.positionItems)
} }
}, },
computed: { computed: {

View File

@@ -1,6 +1,6 @@
<template lang='pug'> <template lang='pug'>
b-modal(@shown="$refs.email.focus()" :title='$t("Login")' hide-footer b-modal(@shown="$refs.email.focus()" :title='$t("Login")' hide-footer
@hidden='$router.replace("/")' :visible='true') @hidden='$router.replace("/")' :visible='true' ref='modal')
el-form el-form
p {{$t('login_explanation')}} p {{$t('login_explanation')}}
el-input.mb-2(v-model='email' type='email' :placeholder='$t("Email")' autocomplete='email' ref='email') el-input.mb-2(v-model='email' type='email' :placeholder='$t("Email")' autocomplete='email' ref='email')
@@ -42,7 +42,7 @@ export default {
Message({ message: this.$t('login error'), type: 'error' }) Message({ message: this.$t('login error'), type: 'error' })
} }
this.email = this.password = '' this.email = this.password = ''
this.$router.replace("/") this.$refs.modal.hide()
} }
} }
} }

View File

@@ -65,6 +65,7 @@ import api from '@/api'
import { mapActions, mapState } from 'vuex' import { mapActions, mapState } from 'vuex'
import moment from 'dayjs' import moment from 'dayjs'
import Calendar from './Calendar' import Calendar from './Calendar'
import { Message } from 'element-ui'
export default { export default {
components: { Calendar }, components: { Calendar },
data() { data() {
@@ -201,11 +202,11 @@ export default {
await this.updateEvent(formData) await this.updateEvent(formData)
} else { } else {
await this.addEvent(formData) await this.addEvent(formData)
// this.$router.push('/')
} }
this.updateMeta() this.updateMeta()
this.sending = false this.sending = false
this.$refs.modal.hide() this.$refs.modal.hide()
Message({ type: 'success', message: this.logged ? this.$t('new_event_added') : this.$t('new_anon_event_added')})
} catch (e) { } catch (e) {
this.sending = false this.sending = false
console.error(e) console.error(e)

View File

@@ -87,6 +87,8 @@ const it = {
<br/>Prima di poter pubblicare <strong>dobbiamo approvare l'account</strong>, considera che <strong>dietro questo sito ci sono delle persone</strong> di <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.`, carne e sangue, scrivici quindi due righe per farci capire che eventi vorresti pubblicare.`,
'Not registered?': `Non sei registrata?`, 'Not registered?': `Non sei registrata?`,
new_event_added: `Evento aggiunto.`,
new_anon_event_added: `Evento inserito, verrà confermato quanto prima.`,
login_explanation: `` login_explanation: ``
} }