Skip to content

Commit

Permalink
Merge pull request #1557 from FJNR-inc/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
RignonNoel authored Sep 12, 2022
2 parents d4c4f67 + b23c6ef commit 9cabdfe
Show file tree
Hide file tree
Showing 23 changed files with 1,044 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lambci/lambda:build-python3.6
FROM lambci/lambda:build-python3.8

LABEL maintainer="[email protected]"

Expand Down
36 changes: 34 additions & 2 deletions blitz_api/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@

from blitz_api.models import Organization, AcademicLevel, AcademicField, \
Address
from retirement.models import Retreat, RetreatDate, RetreatType
from store.models import Order, OptionProduct
from retirement.models import (
Retreat,
RetreatDate,
RetreatType,
Reservation,
)
from store.models import (
Order,
OrderLine,
OptionProduct,
OrderLineBaseProduct
)
from faker import Faker

User = get_user_model()
Expand Down Expand Up @@ -130,6 +140,14 @@ class Meta:
settlement_id = 1


class ReservationFactory(DjangoModelFactory):

class Meta:
model = Reservation

is_active = True


class OptionProductFactory(DjangoModelFactory):
class Meta:
model = OptionProduct
Expand All @@ -139,3 +157,17 @@ class Meta:
available = True
price = 50
max_quantity = 100


class OrderLineFactory(DjangoModelFactory):
class Meta:
model = OrderLine

quantity = 1


class OrderLineBaseProductFactory(DjangoModelFactory):
class Meta:
model = OrderLineBaseProduct

quantity = 1
30 changes: 15 additions & 15 deletions blitz_api/locale/django.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-17 11:13-0400\n"
"POT-Creation-Date: 2022-08-30 10:12-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -231,17 +231,17 @@ msgid "Invalid format."
msgstr ""

#: blitz_api/serializers.py:63 blitz_api/serializers.py:96
#: blitz_api/serializers.py:129 blitz_api/serializers.py:339
#: blitz_api/serializers.py:129 blitz_api/serializers.py:344
#: blitz_api/services.py:125
msgid "This field is required."
msgstr ""

#: blitz_api/serializers.py:181 blitz_api/serializers.py:396
#: blitz_api/serializers.py:541
#: blitz_api/serializers.py:181 blitz_api/serializers.py:401
#: blitz_api/serializers.py:546
msgid "Email address"
msgstr ""

#: blitz_api/serializers.py:196 blitz_api/serializers.py:420
#: blitz_api/serializers.py:196 blitz_api/serializers.py:425
msgid "An account for the specified email address already exists."
msgstr ""

Expand All @@ -257,39 +257,39 @@ msgstr ""
msgid "This university does not exist."
msgstr ""

#: blitz_api/serializers.py:279
msgid "Invalid domain name."
#: blitz_api/serializers.py:281
msgid "You must use your university address to choose this university."
msgstr ""

#: blitz_api/serializers.py:287
#: blitz_api/serializers.py:292
msgid "An account with the same email already exist."
msgstr ""

#: blitz_api/serializers.py:355
#: blitz_api/serializers.py:360
msgid "Bad password"
msgstr ""

#: blitz_api/serializers.py:493
#: blitz_api/serializers.py:498
msgid "Username"
msgstr ""

#: blitz_api/serializers.py:495
#: blitz_api/serializers.py:500
msgid "Password"
msgstr ""

#: blitz_api/serializers.py:511
#: blitz_api/serializers.py:516
msgid "Your account is not activated. [code: not-activated]"
msgstr ""

#: blitz_api/serializers.py:530
#: blitz_api/serializers.py:535
msgid "Unable to log in with provided credentials."
msgstr ""

#: blitz_api/serializers.py:550
#: blitz_api/serializers.py:555
msgid "No account associated to this email address."
msgstr ""

#: blitz_api/serializers.py:597
#: blitz_api/serializers.py:602
msgid "Email already register to this newsletter"
msgstr ""

Expand Down
44 changes: 23 additions & 21 deletions blitz_api/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-08 15:53-0400\n"
"PO-Revision-Date: 2022-03-25 22:32+0000\n"
"Last-Translator: Mélanie Guérin <melanie.guerin@fjnr.ca>\n"
"POT-Creation-Date: 2022-08-30 10:12-0400\n"
"PO-Revision-Date: 2022-08-30 14:24+0000\n"
"Last-Translator: Noel Rignon <noel.rignon@fjnr.ca>\n"
"Language-Team: French <https://weblate.fjnr.ca/projects/tv-blitz-api/"
"blitz_api/fr/>\n"
"Language: fr\n"
Expand Down Expand Up @@ -233,17 +233,17 @@ msgid "Invalid format."
msgstr "Format invalide."

#: blitz_api/serializers.py:63 blitz_api/serializers.py:96
#: blitz_api/serializers.py:129 blitz_api/serializers.py:339
#: blitz_api/serializers.py:129 blitz_api/serializers.py:344
#: blitz_api/services.py:125
msgid "This field is required."
msgstr "Ce champ est requis."

#: blitz_api/serializers.py:181 blitz_api/serializers.py:396
#: blitz_api/serializers.py:541
#: blitz_api/serializers.py:181 blitz_api/serializers.py:401
#: blitz_api/serializers.py:546
msgid "Email address"
msgstr "Adresse e-mail"

#: blitz_api/serializers.py:196 blitz_api/serializers.py:420
#: blitz_api/serializers.py:196 blitz_api/serializers.py:425
msgid "An account for the specified email address already exists."
msgstr "Un compte pour l'adresse e-mail spécifiée existe déjà."

Expand All @@ -259,41 +259,40 @@ msgstr "Ce niveau académique n'existe pas."
msgid "This university does not exist."
msgstr "Cette université n'existe pas."

#: blitz_api/serializers.py:279
msgid "Invalid domain name."
msgstr "Nom de domaine invalide."
#: blitz_api/serializers.py:281
msgid "You must use your university address to choose this university."
msgstr ""
"Tu dois utiliser ton adresse universitaire pour choisir cette université."

#: blitz_api/serializers.py:287
#, fuzzy
#| msgid "An account for the specified email address already exists."
#: blitz_api/serializers.py:292
msgid "An account with the same email already exist."
msgstr "Un compte pour l'adresse e-mail spécifiée existe déjà."
msgstr "Un compte avec la même adresse e-mail existe déjà."

#: blitz_api/serializers.py:355
#: blitz_api/serializers.py:360
msgid "Bad password"
msgstr "Mauvais mot de passe"

#: blitz_api/serializers.py:493
#: blitz_api/serializers.py:498
msgid "Username"
msgstr "Nom d'utilisateur"

#: blitz_api/serializers.py:495
#: blitz_api/serializers.py:500
msgid "Password"
msgstr "Mot de passe"

#: blitz_api/serializers.py:511
#: blitz_api/serializers.py:516
msgid "Your account is not activated. [code: not-activated]"
msgstr "Votre compte n'est pas activé. [code: not-activated]"

#: blitz_api/serializers.py:530
#: blitz_api/serializers.py:535
msgid "Unable to log in with provided credentials."
msgstr "Impossible de se connecter avec les identifiants fournis."

#: blitz_api/serializers.py:550
#: blitz_api/serializers.py:555
msgid "No account associated to this email address."
msgstr "Aucun compte associé à cette adresse e-mail."

#: blitz_api/serializers.py:597
#: blitz_api/serializers.py:602
msgid "Email already register to this newsletter"
msgstr "Cet e-mail est déjà inscrit à cette newsletter"

Expand Down Expand Up @@ -321,3 +320,6 @@ msgid ""
msgstr ""
"Votre token a été créé mais aucun e-mail n'a été envoyé. Veuillez contacter "
"l'administration."

#~ msgid "Invalid domain name."
#~ msgstr "Nom de domaine invalide."
30 changes: 30 additions & 0 deletions blitz_api/migrations/0027_auto_20220902_1049.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 3.2.8 on 2022-09-02 14:49

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('blitz_api', '0026_auto_20220208_1924'),
]

operations = [
migrations.AddField(
model_name='exportmedia',
name='author',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='Author'),
),
migrations.AddField(
model_name='exportmedia',
name='name',
field=models.CharField(blank=True, max_length=512, null=True),
),
migrations.AddField(
model_name='exportmedia',
name='type',
field=models.CharField(choices=[('ANONYMOUS CHRONO', 'Anonymous Chrono'), ('OTHER', 'Other'), ('RETREAT SALES', 'Retreat sales'), ('RETREAT PARTICIPATION', 'Retreat participation'), ('RETREAT OPTIONS', 'Retreat options')], default='OTHER', max_length=255),
),
]
55 changes: 54 additions & 1 deletion blitz_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,63 @@ class Meta:


class ExportMedia(models.Model):
EXPORT_ANONYMOUS_CHRONO_DATA = 'ANONYMOUS CHRONO DATA'
EXPORT_OTHER = 'OTHER'
EXPORT_RETREAT_SALES = 'RETREAT SALES'
EXPORT_RETREAT_PARTICIPATION = 'RETREAT PARTICIPATION'
EXPORT_RETREAT_OPTIONS = 'RETREAT OPTIONS'
EXPORT_RETREAT_ROOM_DISTRIBUTION = 'RETREAT ROOM DISTRIBUTION'

EXPORT_CHOICES = (
(EXPORT_ANONYMOUS_CHRONO_DATA, _('Anonymous Chrono data')),
(EXPORT_OTHER, _('Other')),
(EXPORT_RETREAT_SALES, _('Retreat sales')),
(EXPORT_RETREAT_PARTICIPATION, _('Retreat participation')),
(EXPORT_RETREAT_OPTIONS, _('Retreat options')),
(EXPORT_RETREAT_ROOM_DISTRIBUTION, _('Retreat room distribution')),
)

file = models.FileField(
verbose_name='file',
upload_to='export/%Y/%m/'
)

name = models.CharField(
max_length=512,
blank=True,
null=True
)

author = models.ForeignKey(
settings.AUTH_USER_MODEL,
verbose_name=_('Author'),
on_delete=models.SET_NULL,
null=True,
blank=True,
)

type = models.CharField(
max_length=255,
choices=EXPORT_CHOICES,
default=EXPORT_OTHER,
)

def __str__(self):
return self.file.name
return self.name if self.name else str(self.id)

@property
def size(self):
return self.file.size if self.file else None

def send_confirmation_email(self):
if self.author:
services.send_mail(
[self.author],
{
"USER_FIRST_NAME": self.author.first_name,
"USER_LAST_NAME": self.author.last_name,
"export_link": self.file.url,
},
"EXPORT_DONE",
)

7 changes: 6 additions & 1 deletion blitz_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,12 @@ def validate(self, attrs):
email_d = email.split("@", 1)[1]
if not any(d.name.lower() == email_d.lower() for d in domains):
raise serializers.ValidationError({
'email': [_("Invalid domain name.")]
'email': [
_(
"You must use your university address to "
"choose this university."
)
]
})

if new_email and new_email != old_email:
Expand Down
5 changes: 5 additions & 0 deletions blitz_api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@
'WAIT_QUEUE_RESERVED_SEAT_CREATED',
default='0',
cast=int
),
'EXPORT_DONE': config(
'EXPORT_DONE',
default='67',
cast=int
)
},
}
Expand Down
15 changes: 12 additions & 3 deletions blitz_api/tests/tests_view_UsersId.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,10 @@ def test_partial_update_user_change_email_invalid_domain(self):
)

content = {
'email': ['Invalid domain name.']
'email': [
'You must use your university address to choose this '
'university.'
]
}

self.assertEqual(json.loads(response.content), content)
Expand Down Expand Up @@ -604,7 +607,10 @@ def test_partial_update_user_change_university_invalid_domain(self):
)

content = {
'email': ['Invalid domain name.']
'email': [
'You must use your university address to choose this '
'university.'
]
}

self.assertEqual(json.loads(response.content), content)
Expand Down Expand Up @@ -705,7 +711,10 @@ def test_partial_update_user_change_uni_and_email_invalid_domain(self):
)

content = {
'email': ['Invalid domain name.']
'email': [
'You must use your university address to choose this '
'university.'
]
}

self.assertEqual(json.loads(response.content), content)
Expand Down
Loading

0 comments on commit 9cabdfe

Please sign in to comment.