Skip to content

Commit

Permalink
Merge pull request #222 from FJNR-inc/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
RignonNoel authored Oct 10, 2019
2 parents 8cc2665 + 95f29b1 commit b925309
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 10 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN echo 'export PS1="\[\e[36m\]blitz_shell>\[\e[m\] "' >> /root/.bashrc
COPY requirements.txt /requirements.txt
COPY requirements-dev.txt /requirements-dev.txt

RUN yum update -y && yum install -y postgresql-devel python3-devel
# Virtualenv created for zappa
RUN virtualenv ~/ve
RUN source ~/ve/bin/activate \
Expand Down
1 change: 1 addition & 0 deletions blitz_api/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Meta:

first_name = factory.Faker('first_name')
last_name = factory.Faker('last_name')
language = User.LANGUAGE_FR
username = factory.Sequence(lambda n: f'John{n}')
email = factory.Sequence(lambda n: f'john{n}@blitz.com')
password = 'Test123!'
Expand Down
23 changes: 23 additions & 0 deletions blitz_api/migrations/0021_auto_20191010_1045.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.2.6 on 2019-10-10 14:45

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blitz_api', '0020_auto_20190529_1200'),
]

operations = [
migrations.AddField(
model_name='historicaluser',
name='language',
field=models.CharField(blank=True, choices=[('en', 'English'), ('fr', 'French')], max_length=100, null=True, verbose_name='Language'),
),
migrations.AddField(
model_name='user',
name='language',
field=models.CharField(blank=True, choices=[('en', 'English'), ('fr', 'French')], max_length=100, null=True, verbose_name='Language'),
),
]
13 changes: 13 additions & 0 deletions blitz_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@

class User(AbstractUser):
"""Abstraction of the base User model. Needed to extend in the future."""
LANGUAGE_FR = 'fr'
LANGUAGE_EN = 'en'

GENDER_CHOICES = (
('M', _("Male")),
('F', _("Female")),
('T', _("Trans")),
('A', _("Do not wish to identify myself")),
)
LANGUAGE_CHOICES = (
(LANGUAGE_EN, _('English')),
(LANGUAGE_FR, _('French')),
)

phone = models.CharField(
verbose_name=_("Phone number"),
Expand Down Expand Up @@ -90,6 +96,13 @@ class User(AbstractUser):
choices=GENDER_CHOICES,
verbose_name=_("Gender"),
)
language = models.CharField(
max_length=100,
choices=LANGUAGE_CHOICES,
verbose_name=_("Language"),
null=True,
blank=True
)
membership = models.ForeignKey(
'store.Membership',
blank=True,
Expand Down
2 changes: 2 additions & 0 deletions blitz_api/tests/tests_view_Users.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ def test_list_users(self):
'academic_level',
'academic_field',
'gender',
'language',
'birthdate',
'groups',
'user_permissions',
Expand Down Expand Up @@ -709,6 +710,7 @@ def test_list_users_with_search(self):
'academic_level',
'academic_field',
'gender',
'language',
'birthdate',
'groups',
'user_permissions',
Expand Down
3 changes: 3 additions & 0 deletions blitz_api/tests/tests_view_UsersId.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def setUpClass(cls):
'academic_level',
'academic_field',
'gender',
'language',
'birthdate',
'groups',
'user_permissions',
Expand Down Expand Up @@ -649,6 +650,7 @@ def test_update_user_with_permission(self):
'academic_field': {'name': "random_field"},
'academic_level': {'name': "random_level"},
'gender': "M",
'language': "en",
'birthdate': "1999-11-11",
}

Expand Down Expand Up @@ -676,6 +678,7 @@ def test_update_user_with_permission(self):

# Check if update was successful
self.assertEqual(content['phone'], data['phone'])
self.assertEqual(content['language'], data['language'])
self.assertTrue(self.user.check_password("!321tset"))

# Check id of the user
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pycodestyle==2.5.0
coveralls==1.8.2
responses==0.10.6
six==1.12.0
awscli==1.16.255
awscli==1.16.256
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ python-decouple==3.1
django-storages==1.7.2
dj_database_url==0.5.0
zappa==0.48.2
psycopg2==2.7.5
psycopg2==2.8.3
django-safedelete==0.5.2
-e git+https://github.com/Rhumbix/django-request-logging.git@9342ee6064e678fd162418b142d781550d23101c#egg=django_request_logging
-e git+https://github.com/deschler/django-modeltranslation.git@c8bda494a8cd36b393811552aeee71faf86d7438#egg=django-modeltranslation
Expand Down
18 changes: 13 additions & 5 deletions retirement/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,25 @@ class Meta:
def total_reservations(self):
return self.reservations.filter(is_active=True).count()

def free_places_for_reserve_invitations(self):

places_for_invitations = 0
for invitation in self.invitations.all():
if invitation.reserve_seat:
places_for_invitations += invitation.nb_places_free()

return places_for_invitations

@property
def places_remaining(self):
# Nb places available without invitations
seat_remaining = \
self.seats - self.total_reservations - self.reserved_seats

# Remove places reserved by invitations
for invitation in self.invitations.all():
if invitation.reserve_seat:
seat_remaining = \
seat_remaining - invitation.nb_places_free()
# We remove the free places of invitation to "block" those places
# Because we already count all invitation we remove only
# free places and not all places reserved for invitatioons
seat_remaining -= self.free_places_for_reserve_invitations()

return seat_remaining

Expand Down
1 change: 1 addition & 0 deletions retirement/tests/tests_viewset_Reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def test_create(self):
'academic_level': None,
'birthdate': None,
'gender': None,
'language': User.LANGUAGE_FR,
'groups': [],
'id': self.user.id,
'is_active': True,
Expand Down
6 changes: 3 additions & 3 deletions retirement/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,18 +432,18 @@ def destroy(self, request, *args, **kwargs):
instance.cancelation_date = timezone.now()
instance.save()

free_seats = retreat.seats - retreat.total_reservations
free_seats = retreat.places_remaining
if retreat.reserved_seats or free_seats == 1:
retreat.reserved_seats += 1

retrat_notification_url = request.build_absolute_uri(
retreat_notification_url = request.build_absolute_uri(
reverse(
'retreat:retreat-notify',
args=[retreat.id]
)
),
retreat.notify_scheduler_waite_queue(
retrat_notification_url)
retreat_notification_url)

retreat.save()

Expand Down

0 comments on commit b925309

Please sign in to comment.