0001-agendas-add-almost_full-event-flag-44158.patch
chrono/agendas/migrations/0057_event_almost_full.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
# Generated by Django 1.11.18 on 2020-07-29 09:50 |
|
3 |
from __future__ import unicode_literals |
|
4 | ||
5 |
from django.db import migrations, models |
|
6 | ||
7 | ||
8 |
class Migration(migrations.Migration): |
|
9 | ||
10 |
dependencies = [ |
|
11 |
('agendas', '0056_event_cancelled'), |
|
12 |
] |
|
13 | ||
14 |
operations = [ |
|
15 |
migrations.AddField( |
|
16 |
model_name='event', name='almost_full', field=models.BooleanField(default=False), |
|
17 |
), |
|
18 |
] |
chrono/agendas/models.py | ||
---|---|---|
773 | 773 |
) |
774 | 774 |
pricing = models.CharField(_('Pricing'), max_length=150, null=True, blank=True) |
775 | 775 |
url = models.CharField(_('URL'), max_length=200, null=True, blank=True) |
776 |
almost_full = models.BooleanField(default=False) |
|
776 | 777 |
full = models.BooleanField(default=False) |
777 | 778 |
cancelled = models.BooleanField( |
778 | 779 |
default=False, help_text=_("Cancel this event so that it won't be bookable anymore.") |
... | ... | |
812 | 813 |
(self.booked_places >= self.places and self.waiting_list_places == 0) |
813 | 814 |
or (self.waiting_list_places and self.waiting_list >= self.waiting_list_places) |
814 | 815 |
) |
816 |
self.almost_full = bool(self.booked_places >= 0.9 * self.places) |
|
815 | 817 | |
816 | 818 |
def in_bookable_period(self): |
817 | 819 |
if self.publication_date and localtime(now()).date() < self.publication_date: |
... | ... | |
967 | 969 |
def save(self, *args, **kwargs): |
968 | 970 |
with transaction.atomic(): |
969 | 971 |
super(Booking, self).save(*args, **kwargs) |
970 |
initial_value = self.event.full
|
|
972 |
initial_values = self.event.full, self.event.almost_full
|
|
971 | 973 |
self.event.check_full() |
972 |
if self.event.full != initial_value:
|
|
974 |
if (self.event.full, self.event.almost_full) != initial_values:
|
|
973 | 975 |
self.event.save() |
974 | 976 | |
975 | 977 |
def cancel(self, trigger_callback=True): |
976 |
- |