Skip to content

Commit

Permalink
Adds button to switch between informing / not informing the user when…
Browse files Browse the repository at this point in the history
… revoking a reservation. Fixes #10
  • Loading branch information
href committed Oct 4, 2013
1 parent 7ee5360 commit 526ea81
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 31 deletions.
5 changes: 5 additions & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

1.0.14 (unreleased)
-------------------

- Adds the ability to remove a reservation without sending an email.

1.0.13
------

Expand Down
6 changes: 4 additions & 2 deletions seantis/reservation/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,15 +1016,17 @@ def deny_reservation(self, token):
notify(ReservationDeniedEvent(reservation, self.language))

@serialized
def revoke_reservation(self, token, reason):
def revoke_reservation(self, token, reason, send_email=True):
""" Revoke a reservation and inform the user of that."""

reason = reason or u''

# sending the email first is no problem as it won't work if
# an exception triggers later in the request
reservation = self.reservation_by_token(token).one()
notify(ReservationRevokedEvent(reservation, self.language, reason))
notify(ReservationRevokedEvent(
reservation, self.language, reason, send_email
))

self.remove_reservation(token)

Expand Down
3 changes: 2 additions & 1 deletion seantis/reservation/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ class ReservationDeniedEvent(ReservationBaseEvent):
class ReservationRevokedEvent(ReservationBaseEvent):
implements(IReservationRevokedEvent)

def __init__(self, reservation, language, reason):
def __init__(self, reservation, language, reason, send_email):
super(ReservationRevokedEvent, self).__init__(reservation, language)
self.reason = reason
self.send_email = send_email


class ReservationsConfirmedEvent(object):
Expand Down
8 changes: 8 additions & 0 deletions seantis/reservation/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,14 @@ class IGroupReservation(Interface):
class IRevokeReservation(IReservationIdForm):
""" For the reservation revocation form. """

send_email = schema.Bool(
title=_(u"Send Email"),
description=_(
u"Send an email to the reservee informing him of the revocation"
),
default=True
)

reason = schema.Text(
title=_(u'Reason'),
description=_(
Expand Down
11 changes: 11 additions & 0 deletions seantis/reservation/js/formgroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,17 @@ seantis.formgroups.init = function(el) {
}
});

add({
name: "send_email",
trigger: find('#form-widgets-send_email-0'),
fields: [
find('#formfield-form-widgets-reason')
],
on_is_enabled: function(trigger) {
return trigger.is(':checked');
}
})

seantis.formgroups.add_utility_links();
seantis.formgroups.add_recurrency_helper();
seantis.formgroups.autoselect_days();
Expand Down
34 changes: 21 additions & 13 deletions seantis/reservation/locales/de/LC_MESSAGES/seantis.reservation.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-09-27 08:57+0000\n"
"POT-Creation-Date: 2013-10-04 08:02+0000\n"
"PO-Revision-Date: 2012-09-06 11:33+0100\n"
"Last-Translator: Fabian Reinhard <fabian.reinhard@seantis.ch>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -14,7 +14,7 @@ msgstr ""
"Preferred-Encodings: utf-8 latin1\n"
"Domain: DOMAIN\n"

#: ./reports/latest_reservations.py:54
#: ./reports/latest_reservations.py:37
msgid "${days} days ago, at ${time}"
msgstr "Vor ${days} Tagen, um ${time}"

Expand Down Expand Up @@ -62,7 +62,7 @@ msgstr "Es existiert bereits eine Einteilung für den gewählten Zeitraum"
msgid "A pending reservation would be affected by the requested change"
msgstr "Ein offene Reservierung wäre durch die Änderung betroffen"

#: ./mail.py:486
#: ./mail.py:489
msgid "Add email template"
msgstr "Email Vorlage hinzufügen"

Expand Down Expand Up @@ -207,7 +207,7 @@ msgid "Defines the minimum length of any given reservation as well as the alignm
msgstr "Definiert die Mindestlänge der Reservationen für diese Einteilung, sowie die automatische Anpassung der Start- bzw. Endzeit. Ein Raster von 30 Minuten bedeuted beispielsweise, dass die Einteilung nur um xx:00 Uhr und xx:30 Uhr beginnen kann."

#: ./allocate.py:297
#: ./mail.py:495
#: ./mail.py:498
#: ./reports/monthly_report.py:220
msgid "Delete"
msgstr "Löschen"
Expand Down Expand Up @@ -251,7 +251,7 @@ msgid "Do you want to reserve the following allocations?"
msgstr "Möchten Sie die folgenden Einteilungen reservieren?"

#: ./allocate.py:244
#: ./mail.py:494
#: ./mail.py:497
#: ./resource.py:342
msgid "Edit"
msgstr "Bearbeiten"
Expand Down Expand Up @@ -301,7 +301,7 @@ msgstr "Email Betreff für Reservationen in der Warteliste"
msgid "Email Subject for Revoked Reservations"
msgstr "Email Betreff für Abgesagte Reservationen"

#: ./mail.py:89
#: ./mail.py:92
#: ./profiles/default/types/seantis.reservation.emailtemplate.xml
msgid "Email Template"
msgstr "Email Vorlage"
Expand Down Expand Up @@ -540,7 +540,7 @@ msgstr "Ohne"
msgid "One Person Waiting"
msgstr "Eine Person wartet"

#: ./interfaces.py:770
#: ./interfaces.py:778
msgid "Optional reason for the revocation. Sent to the reservee. e.g. 'Your reservation has to be cancelled because the lecturer is ill'."
msgstr "Optionaler Grund für die Absage. Wird an den Reservierenden gesendet. Z.B. 'Ihre Reservation muss abesagt werden weil der Dozent krank ist'."

Expand Down Expand Up @@ -575,7 +575,7 @@ msgstr "Kontingent muss zwischen 1 und 1000 liegen"
msgid "Raster"
msgstr "Raster"

#: ./interfaces.py:769
#: ./interfaces.py:777
msgid "Reason"
msgstr "Grund"

Expand Down Expand Up @@ -665,7 +665,7 @@ msgstr "Reservierung erfolgreich abgeschlossen"
msgid "Reservations can't be made for more than 24 hours at a time"
msgstr "Reservationen können nicht über mehr als 24 Stunden gemacht werden"

#: ./reports/latest_reservations.py:29
#: ./reports/latest_reservations.py:56
msgid "Reservations in the last 30 days"
msgstr "Reservationen in den letzten 30 Tagen"

Expand Down Expand Up @@ -704,7 +704,7 @@ msgstr "Reservation absagen"
msgid "Sa"
msgstr "Sa"

#: ./mail.py:438
#: ./mail.py:441
#: ./reserve.py:861
#: ./timeframe.py:83
msgid "Save"
Expand Down Expand Up @@ -734,6 +734,14 @@ msgstr "Ausgewählte Ansicht"
msgid "Selected view when opening the calendar."
msgstr "Ansicht die beim Öffnen des Kalenders angezeigt wird."

#: ./interfaces.py:769
msgid "Send Email"
msgstr "Email senden"

#: ./interfaces.py:770
msgid "Send an email to the reservee informing him of the revocation"
msgstr "Informiere den Benutzer der die Reservation gemacht hat"

#: ./settings.py:40
msgid "Send emails about made, approved and denied reservations to the user that made the reservation."
msgstr "Sende Emails zu gemachten, zugelassenen und abgelehnten Reservationen zu dem Benutzer der die Reservation gemacht hat."
Expand Down Expand Up @@ -887,7 +895,7 @@ msgstr "${nb} Reservationen werden gerade eingegeben."
msgid "There is one reservation being entered for this resource."
msgstr "Eine Reservation wird gerade eingegeben."

#: ./mail.py:423
#: ./mail.py:426
msgid "There's already an Email template in the same folder for the same language"
msgstr "Es besteht bereits eine Email Vorlage mit dieser Sprache in diesem Order"

Expand All @@ -908,7 +916,7 @@ msgstr "Belegungsperioden"
msgid "Timetable"
msgstr "Zeitachse"

#: ./reports/latest_reservations.py:45
#: ./reports/latest_reservations.py:28
msgid "Today, at ${time}"
msgstr "Heute, um ${time}"

Expand Down Expand Up @@ -966,7 +974,7 @@ msgstr "Ganztägig"
msgid "Yes"
msgstr "Ja"

#: ./reports/latest_reservations.py:50
#: ./reports/latest_reservations.py:33
msgid "Yesterday, at ${time}"
msgstr "Gestern, um ${time}"

Expand Down
34 changes: 21 additions & 13 deletions seantis/reservation/locales/seantis.reservation.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-09-27 08:57+0000\n"
"POT-Creation-Date: 2013-10-04 08:02+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -17,7 +17,7 @@ msgstr ""
"Preferred-Encodings: utf-8 latin1\n"
"Domain: seantis.reservation\n"

#: ./reports/latest_reservations.py:54
#: ./reports/latest_reservations.py:37
msgid "${days} days ago, at ${time}"
msgstr ""

Expand Down Expand Up @@ -65,7 +65,7 @@ msgstr ""
msgid "A pending reservation would be affected by the requested change"
msgstr ""

#: ./mail.py:486
#: ./mail.py:489
msgid "Add email template"
msgstr ""

Expand Down Expand Up @@ -210,7 +210,7 @@ msgid "Defines the minimum length of any given reservation as well as the alignm
msgstr ""

#: ./allocate.py:297
#: ./mail.py:495
#: ./mail.py:498
#: ./reports/monthly_report.py:220
msgid "Delete"
msgstr ""
Expand Down Expand Up @@ -254,7 +254,7 @@ msgid "Do you want to reserve the following allocations?"
msgstr ""

#: ./allocate.py:244
#: ./mail.py:494
#: ./mail.py:497
#: ./resource.py:342
msgid "Edit"
msgstr ""
Expand Down Expand Up @@ -304,7 +304,7 @@ msgstr ""
msgid "Email Subject for Revoked Reservations"
msgstr ""

#: ./mail.py:89
#: ./mail.py:92
#: ./profiles/default/types/seantis.reservation.emailtemplate.xml
msgid "Email Template"
msgstr ""
Expand Down Expand Up @@ -543,7 +543,7 @@ msgstr ""
msgid "One Person Waiting"
msgstr ""

#: ./interfaces.py:770
#: ./interfaces.py:778
msgid "Optional reason for the revocation. Sent to the reservee. e.g. 'Your reservation has to be cancelled because the lecturer is ill'."
msgstr ""

Expand Down Expand Up @@ -578,7 +578,7 @@ msgstr ""
msgid "Raster"
msgstr ""

#: ./interfaces.py:769
#: ./interfaces.py:777
msgid "Reason"
msgstr ""

Expand Down Expand Up @@ -668,7 +668,7 @@ msgstr ""
msgid "Reservations can't be made for more than 24 hours at a time"
msgstr ""

#: ./reports/latest_reservations.py:29
#: ./reports/latest_reservations.py:56
msgid "Reservations in the last 30 days"
msgstr ""

Expand Down Expand Up @@ -707,7 +707,7 @@ msgstr ""
msgid "Sa"
msgstr ""

#: ./mail.py:438
#: ./mail.py:441
#: ./reserve.py:861
#: ./timeframe.py:83
msgid "Save"
Expand Down Expand Up @@ -737,6 +737,14 @@ msgstr ""
msgid "Selected view when opening the calendar."
msgstr ""

#: ./interfaces.py:769
msgid "Send Email"
msgstr ""

#: ./interfaces.py:770
msgid "Send an email to the reservee informing him of the revocation"
msgstr ""

#: ./settings.py:40
msgid "Send emails about made, approved and denied reservations to the user that made the reservation."
msgstr ""
Expand Down Expand Up @@ -890,7 +898,7 @@ msgstr ""
msgid "There is one reservation being entered for this resource."
msgstr ""

#: ./mail.py:423
#: ./mail.py:426
msgid "There's already an Email template in the same folder for the same language"
msgstr ""

Expand All @@ -911,7 +919,7 @@ msgstr ""
msgid "Timetable"
msgstr ""

#: ./reports/latest_reservations.py:45
#: ./reports/latest_reservations.py:28
msgid "Today, at ${time}"
msgstr ""

Expand Down Expand Up @@ -969,7 +977,7 @@ msgstr ""
msgid "Yes"
msgstr ""

#: ./reports/latest_reservations.py:50
#: ./reports/latest_reservations.py:33
msgid "Yesterday, at ${time}"
msgstr ""

Expand Down
3 changes: 3 additions & 0 deletions seantis/reservation/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def on_reservation_revoked(event):
if not settings.get('send_email_to_reservees', True):
return

if not event.send_email:
return

send_reservation_mail(
event.reservation, 'reservation_revoked', event.language,
to_managers=False, revocation_reason=event.reason
Expand Down
2 changes: 1 addition & 1 deletion seantis/reservation/reserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def revoke(self, data):

def revoke():
self.scheduler.revoke_reservation(
data['reservation'], data['reason']
data['reservation'], data['reason'], data['send_email']
)
self.flash(_(u'Reservation revoked'))

Expand Down
10 changes: 10 additions & 0 deletions seantis/reservation/tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,16 @@ def assert_data_in_mail(message, assert_as=True):
self.assertTrue(u'no-reason' in mail.messages[0])
mail.messages = []

# unless it should not be sent
token = sc.reserve(
reservation_email,
dates, data=data, session_id=session_id
)
sc.approve_reservation(token)
mail.messages = []
sc.revoke_reservation(token, u'', send_email=False)
self.assertEqual(len(mail.messages), 0)

sc.remove_allocation(allocation.id)

# make multiple reservations in one session to different email
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

name = "seantis.reservation"
description = "Plone addon to reserve stuff in a calendar."
version = '1.0.13'
version = '1.0.14'

zug_require = [
'ftw.contentmenu',
Expand Down

0 comments on commit 526ea81

Please sign in to comment.