Make it possible to make waitlist offers until a certain time
authorMagnus Hagander <magnus@hagander.net>
Mon, 9 Jul 2018 12:01:56 +0000 (14:01 +0200)
committerMagnus Hagander <magnus@hagander.net>
Mon, 9 Jul 2018 12:04:12 +0000 (14:04 +0200)
Previously it was only possible to say "<n>" hours, which made the
administrator do the calculation to make sure the offer didn't expire in
the middle of the night etc.

With this it's now possible to either extend an offer for a certain
number of hours, or until a certain point in time.

In both cases, the fields default to 48 hours from the current time.

docs/confreg/waitlist.md
media/css/confadmin.css
postgresqleu/confreg/forms.py
postgresqleu/confreg/views.py
template/confreg/admin_waitlist.html

index b86635e871dc20beefbe6336352293903b693c1e..96189970722db82e95b5e1b23b36ccdb90df3de4 100644 (file)
@@ -13,11 +13,15 @@ administrators.
 
 One or more attendees can be given an *offer* from the waitlist. This
 offer is given an expiry time, giving the chance to sign up before
-that time. The length of the offer is usually adapted to how much time
-is left until the conference -- to make sure that if the attendee
-doesn't take the offer, there is enough time to give it to somebody
-else. The system does *not* take things like office hours into account
-when calculating the offer time, that has to be done manually.
+that time. The expiry time can either be given as number of hours from
+the current time or as an explicit point in time, depending on which
+field/button combination is used. The length of the offer is usually
+adapted to how much time is left until the conference -- to make sure
+that if the attendee doesn't take the offer, there is enough time to
+give it to somebody else. The system does *not* take things like
+office hours into account when calculating the offer time, that has to
+be done manually (and usually using the make offer until specific
+point in time button).
 
 Offers should always be given from the top of the waitlist. This will
 make sure that those who signed up early gets a chance first. The
index a96103c02f075409c71ce27c35b5e2c8092213f9..6f1deaec2e14bba68e5e02246f91c5aa360a02cb 100644 (file)
@@ -9,3 +9,8 @@ div.backendform_checkbox ul {
 div.backenddocs dd {
     margin-left: 2em;
 }
+
+table.borderless tr td,
+table.borderless tr th {
+    border: none;
+}
index 48c3532cbbb429ce06b3d9973e34b5270ae2fc8e..3da0479ce4ef968323910457e4d4ab82ce17d17f 100644 (file)
@@ -18,7 +18,7 @@ from postgresqleu.util.magic import magicdb
 
 from postgresqleu.countries.models import Country
 
-from datetime import datetime, date
+from datetime import datetime, date, timedelta
 import requests
 
 
@@ -615,13 +615,18 @@ class AttendeeMailForm(forms.ModelForm):
 
 class WaitlistOfferForm(forms.Form):
        hours = forms.IntegerField(min_value=1, max_value=240, label='Offer valid for (hours)', initial=48)
+       until = forms.DateTimeField(label='Offer valid until', initial=(datetime.now() + timedelta(hours=48)).strftime('%Y-%m-%d %H:%M'))
        confirm = forms.BooleanField(help_text='Confirm')
 
        def __init__(self, *args, **kwargs):
                super(WaitlistOfferForm, self).__init__(*args, **kwargs)
-               if self.data and self.data.has_key('hours'):
+               if self.data:
                        self.reg_list = self._get_id_list_from_data()
                        self.fields['confirm'].help_text = "Confirm that you want to send an offer to {0} attendees on the waitlist".format(len(self.reg_list))
+                       if self.data.get('submit') == 'Make offer for hours':
+                               del self.fields['until']
+                       else:
+                               del self.fields['hours']
                else:
                        del self.fields['confirm']
 
index a0a4156591b6d95e4ec7809766c383f9ab584f60..05560add84d863afe8e16692fa07fe820b9fcc57 100644 (file)
@@ -2605,10 +2605,15 @@ def admin_waitlist(request, urlname):
                                if wl.offeredon:
                                        raise Exception("One or more already offered!")
                                wl.offeredon = datetime.now()
-                               wl.offerexpires = datetime.now() + timedelta(hours=form.cleaned_data['hours'])
+                               if request.POST.get('submit') == 'Make offer for hours':
+                                       wl.offerexpires = datetime.now() + timedelta(hours=form.cleaned_data['hours'])
+                                       RegistrationWaitlistHistory(waitlist=wl,
+                                                                                               text="Made offer valid for {0} hours by {1}".format(form.cleaned_data['hours'], request.user.username)).save()
+                               else:
+                                       wl.offerexpires = form.cleaned_data['until']
+                                       RegistrationWaitlistHistory(waitlist=wl,
+                                                                                               text="Made offer valid until {0} by {1}".format(form.cleaned_data['until'], request.user.username)).save()
                                wl.save()
-                               RegistrationWaitlistHistory(waitlist=wl,
-                                                                                       text="Made offer valid for {0} hours by {1}".format(form.cleaned_data['hours'], request.user.username)).save()
                                send_template_mail(conference.contactaddr,
                                                                   r.email,
                                                                   "Your waitlisted registration for {0}".format(conference.conferencename),
index db0c4a325a6f865059a0b0a80939acb0d56ee613..d6c9d218757cf2903717708c157999896160fd2d 100644 (file)
@@ -87,10 +87,49 @@ The current entries on the waitlist are:
 {%include "confreg/admin_waitlist_list.inc.html"%}
 {%endwith%}
 
-<table>
-{{form}}
+<table class="table borderless">
+  <tr>
+{%if form.hours%}
+    <td class="col-md-3">{{form.hours.label}}</td>
+    <td class="col-md-3">{{form.hours}}</td>
+{%else%}
+    <td colspan="2" class="col-md-6"></td>
+{%endif%}
+{%if form.until%}
+    <td class="col-md-3">{{form.until.label}}</td>
+    <td class="col-md-3">{{form.until}}</td>
+{%else%}
+    <td colspan="2" class="col-md-6"></td>
+{%endif%}
+  </tr>
+{%if form.confirm%}
+  <tr>
+    <td colspan="4" class="col-md-12 warning">{{form.confirm}} {{form.confirm.help_text}}</td>
+  </tr>
+{%endif%}
+  <tr>
+    <td colspan="2" class="col-md-6">
+{%if form.hours%}
+      <input type="submit" name="submit" value="Make offer for hours" class="btn btn-default">
+{%else%}
+    </td>
+{%endif%}
+    <td colspan="2" class="col-md-6">
+{%if form.until%}
+      <input type="submit" name="submit" value="Make offer until" class="btn btn-default"></td>
+{%else%}
+    </td>
+{%endif%}
+  </tr>
+{%if form.confirm%}
+  <tr>
+    <td colspan="4" class="col-md-12">
+      <a href="." class="btn btn-default btn-block">Cancel</a>
+    </td>
+  </tr>
+{%endif%}
+
 </table>
-<input type="submit" value="Make offer">
 </form>
 
 <h3>Processed waitlist</h3>