diff --git a/DjangoFiles/Administration/admin_tenant.py b/DjangoFiles/Administration/admin_tenant.py index 29dd319..9d11528 100644 --- a/DjangoFiles/Administration/admin_tenant.py +++ b/DjangoFiles/Administration/admin_tenant.py @@ -115,7 +115,7 @@ class ConfigurationAdmin(SingletonModelAdmin): 'map_img', ) }), - ('Réstaurant', { + ('Restaurant', { 'fields': ( 'carte_restaurant', ), @@ -144,6 +144,8 @@ class ConfigurationAdmin(SingletonModelAdmin): ('Billetterie', { 'fields': ( 'activer_billetterie', + 'template_billetterie', + 'template_meta', 'name_required_for_ticket', 'jauge_max', 'option_generale_radio', diff --git a/DjangoFiles/BaseBillet/migrations/0021_auto_20211206_1810.py b/DjangoFiles/BaseBillet/migrations/0021_auto_20211206_1810.py new file mode 100644 index 0000000..e20af54 --- /dev/null +++ b/DjangoFiles/BaseBillet/migrations/0021_auto_20211206_1810.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2 on 2021-12-06 14:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('BaseBillet', '0020_auto_20211111_1219'), + ] + + operations = [ + migrations.AddField( + model_name='configuration', + name='template_billetterie', + field=models.CharField(blank=True, choices=[('html5up-massively', 'html5up-massively'), ('arnaud_mvc', 'arnaud_mvc'), ('original_arnaud', 'original_arnaud')], max_length=250, null=True, verbose_name='Template'), + ), + migrations.AddField( + model_name='configuration', + name='template_meta', + field=models.CharField(blank=True, choices=[('html5up-massively', 'html5up-massively'), ('arnaud_mvc', 'arnaud_mvc'), ('original_arnaud', 'original_arnaud')], max_length=250, null=True, verbose_name='Template'), + ), + ] diff --git a/DjangoFiles/BaseBillet/models.py b/DjangoFiles/BaseBillet/models.py index 480f789..1e8bac5 100644 --- a/DjangoFiles/BaseBillet/models.py +++ b/DjangoFiles/BaseBillet/models.py @@ -1,3 +1,4 @@ +import os import uuid import requests @@ -73,17 +74,17 @@ class Configuration(SingletonModel): name_required_for_ticket = models.BooleanField(default=False, verbose_name=_("Billet nominatifs")) map_img = StdImageField(upload_to='images/', - null=True, blank=True, - validators=[MaxSizeValidator(1920, 1920)], - variations={ - 'fhd': (1920, 1920), - 'hdr': (720, 720), - 'med': (480, 480), - 'thumbnail': (150, 90), - }, - delete_orphans=True, - verbose_name=_('Carte géorgraphique') - ) + null=True, blank=True, + validators=[MaxSizeValidator(1920, 1920)], + variations={ + 'fhd': (1920, 1920), + 'hdr': (720, 720), + 'med': (480, 480), + 'thumbnail': (150, 90), + }, + delete_orphans=True, + verbose_name=_('Carte géorgraphique') + ) carte_restaurant = StdImageField(upload_to='images/', null=True, blank=True, @@ -112,17 +113,17 @@ class Configuration(SingletonModel): ) logo = StdImageField(upload_to='images/', - null=True, blank=True, - # validators=[MaxSizeValidator(1920, 1920)], - variations={ - 'fhd': (1920, 1920), - 'hdr': (720, 720), - 'med': (480, 480), - 'thumbnail': (300, 120), - }, - delete_orphans=True, - verbose_name='Logo' - ) + null=True, blank=True, + # validators=[MaxSizeValidator(1920, 1920)], + variations={ + 'fhd': (1920, 1920), + 'hdr': (720, 720), + 'med': (480, 480), + 'thumbnail': (300, 120), + }, + delete_orphans=True, + verbose_name='Logo' + ) mollie_api_key = models.CharField(max_length=50, blank=True, null=True) @@ -157,6 +158,22 @@ class Configuration(SingletonModel): verbose_name=_("Clé d'API du serveur cashless") ) + template_billetterie = models.CharField( + choices=[(folder, folder) for folder in os.listdir(f"{settings.BASE_DIR}/BaseBillet/templates")], + max_length=250, + blank=True, + null=True, + verbose_name=_("Template Billetterie") + ) + + template_meta = models.CharField( + choices=[(folder, folder) for folder in os.listdir(f"{settings.BASE_DIR}/MetaBillet/templates")], + max_length=250, + blank=True, + null=True, + verbose_name=_("Template Meta") + ) + class Product(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True, db_index=True) @@ -348,7 +365,7 @@ class Event(models.Model): return f"{self.datetime.strftime('%d/%m')} {self.name}" class Meta: - unique_together = ('name','datetime') + unique_together = ('name', 'datetime') ordering = ('datetime',) verbose_name = _('Evenement') verbose_name_plural = _('Evenements') @@ -463,7 +480,6 @@ class Ticket(models.Model): f"{self.last_name.capitalize()}" \ f".pdf" - def pdf_url(self): domain = connection.tenant.domains.all().first().domain api_pdf = reverse("ticket_uuid_to_pdf", args=[f"{self.uuid}"]) @@ -474,7 +490,6 @@ class Ticket(models.Model): port = ":8002" return f"{protocol}{domain}{port}{api_pdf}" - def event(self): return self.reservation.event @@ -528,7 +543,6 @@ class Paiement_stripe(models.Model): reservation = models.ForeignKey(Reservation, on_delete=models.PROTECT, blank=True, null=True, related_name="paiements") - QRCODE, API_BILLETTERIE = 'Q', 'B' SOURCE_CHOICES = ( (QRCODE, _('Depuis scan QR-Code')), diff --git a/DjangoFiles/BaseBillet/templates/arnaud_mvc/lieux.html b/DjangoFiles/BaseBillet/templates/arnaud_mvc/index.html similarity index 100% rename from DjangoFiles/BaseBillet/templates/arnaud_mvc/lieux.html rename to DjangoFiles/BaseBillet/templates/arnaud_mvc/index.html diff --git a/DjangoFiles/BaseBillet/views.py b/DjangoFiles/BaseBillet/views.py index 7482b24..c5d7f92 100644 --- a/DjangoFiles/BaseBillet/views.py +++ b/DjangoFiles/BaseBillet/views.py @@ -37,7 +37,11 @@ class index(APIView): # return render(request, 'html5up-massively/index.html', context=context) # return render(request, self.template_name , context=context) - return render(request, 'arnaud_mvc/lieux.html', context=context) + + if configuration.template_billetterie : + return render(request, f'{configuration.template_billetterie}/index.html', context=context) + else : + return render(request, 'arnaud_mvc/index.html', context=context) # class adhesion(APIView):