diff --git a/app/controller/event.js b/app/controller/event.js index d7d9f2a4..933118ce 100644 --- a/app/controller/event.js +++ b/app/controller/event.js @@ -28,6 +28,11 @@ const eventController = { function match (event, filters) { // matches if no filter specified 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) { 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 event = await Event.findByPk(id) - // insert notification - const notifications = await eventController.getNotifications(event) - await event.setNotifications(notifications) - try { await event.update({ is_visible: true }) + // insert notification + const notifications = await eventController.getNotifications(event) + await event.setNotifications(notifications) res.send(200) } catch (e) { res.send(404) diff --git a/app/controller/export.js b/app/controller/export.js index 407b8b4e..00ece085 100644 --- a/app/controller/export.js +++ b/app/controller/export.js @@ -21,7 +21,7 @@ const exportController = { wherePlace.name = places.split(',') } const events = await Event.findAll({ - order: [['start_datetime', 'ASC']], + // order: [['start_datetime', 'ASC']], where: { start_datetime: { [Op.gte]: yesterday } }, include: [Comment, { model: Tag, diff --git a/app/controller/user.js b/app/controller/user.js index fa8dbf2e..19d396e1 100644 --- a/app/controller/user.js +++ b/app/controller/user.js @@ -105,11 +105,10 @@ const userController = { if (req.user) await req.user.addEvent(event) event = await Event.findByPk(event.id, { include: [User, Tag, Place] }) - if (req.user) { - // insert notifications - const notifications = await eventController.getNotifications(event) - await event.setNotifications(notifications) - } + // insert notifications + const notifications = await eventController.getNotifications(event) + await event.setNotifications(notifications) + return res.json(event) }, diff --git a/app/emails/event/html.pug b/app/emails/event/html.pug index 8c397e48..72b0151d 100644 --- a/app/emails/event/html.pug +++ b/app/emails/event/html.pug @@ -2,14 +2,17 @@ h3 #{event.title} p Dove: #{event.place.name} - #{event.place.address} p Quando: #{datetime(event.start_datetime)} br - +if event.image_path + p #{event.description} +each tag in event.tags + span ##{tag.tag} +br #{config.baseurl}/event/#{event.id} -p #{event.tags.join(', ')} hr if to_confirm - p Puoi confermare questo evento #{config.apiurl}qui -else + p Puoi confermare questo evento qui +//- else p Puoi eliminare queste notifiche qui #{config.title} - #{config.description} diff --git a/app/models/event.js b/app/models/event.js index 80ea88d8..ed894783 100644 --- a/app/models/event.js +++ b/app/models/event.js @@ -34,8 +34,8 @@ const Notification = db.define('notification', { } }) -Notification.findOrCreate({ where: { type: 'mastodon' } }) -Notification.findOrCreate({ where: { type: 'admin_email' } }) +Notification.findOrCreate({ where: { type: 'mastodon', filters: { is_visible: true } } }) +Notification.findOrCreate({ where: { type: 'admin_email', filters: { is_visible: false } } }) const Place = db.define('place', { name: { type: Sequelize.STRING, unique: true, index: true }, diff --git a/client/src/components/Admin.vue b/client/src/components/Admin.vue index 0acc1f1e..ed85b2f6 100644 --- a/client/src/components/Admin.vue +++ b/client/src/components/Admin.vue @@ -144,7 +144,6 @@ export default { }, methods: { placeSelected (items) { - console.log('dentro place selected ', items, items.length) if (items.length === 0 ) { this.place.name = this.place.address = '' return diff --git a/client/src/components/Home.vue b/client/src/components/Home.vue index e5c71ebc..05b50704 100644 --- a/client/src/components/Home.vue +++ b/client/src/components/Home.vue @@ -23,7 +23,7 @@ export default { components: { Event, Calendar, Search }, watch: { filteredEvents () { - this.$nextTick( this.$refs.magicgrid.positionItems) + this.$nextTick(this.$refs.magicgrid.positionItems) } }, computed: { diff --git a/client/src/components/Login.vue b/client/src/components/Login.vue index aeb4dd72..7f09610a 100644 --- a/client/src/components/Login.vue +++ b/client/src/components/Login.vue @@ -1,6 +1,6 @@