From 5bdc4f8b69717580be554c677d93738d2778bf0d Mon Sep 17 00:00:00 2001 From: yaemiku Date: Sat, 5 Nov 2022 17:05:06 +0100 Subject: [PATCH] [func] enable tournament buttons --- tournamentpages/admin.py | 14 +++--- ...amentpage_accomodation_buttons_and_more.py | 43 +++++++++++++++++++ .../0003_tournamentpage_homepage_buttons.py | 18 ++++++++ tournamentpages/models.py | 39 +++++++++++++++++ tournamentpages/templates/tournament.html | 13 +++--- tournamentpages/views.py | 14 +++--- 6 files changed, 122 insertions(+), 19 deletions(-) create mode 100644 tournamentpages/migrations/0002_tournamentpage_accomodation_buttons_and_more.py create mode 100644 tournamentpages/migrations/0003_tournamentpage_homepage_buttons.py diff --git a/tournamentpages/admin.py b/tournamentpages/admin.py index bcf117c..0fcda56 100644 --- a/tournamentpages/admin.py +++ b/tournamentpages/admin.py @@ -20,43 +20,43 @@ class BandAdmin(TabbedModelAdmin): tab_homepage = ( (None, { - 'fields': ('homepage',) + 'fields': ('homepage', 'homepage_buttons') }), ) tab_schedule_and_results = ( (None, { - 'fields': ('schedule_and_results', 'schedule_and_results_enabled') + 'fields': ('schedule_and_results', 'schedule_and_results_enabled', 'schedule_and_results_buttons') }), ) tab_registration = ( (None, { - 'fields': ('registration', 'registration_enabled') + 'fields': ('registration', 'registration_enabled', 'registration_buttons') }), ) tab_rules = ( (None, { - 'fields': ('rules', 'rules_enabled') + 'fields': ('rules', 'rules_enabled', 'rules_buttons') }), ) tab_fee_and_prizes = ( (None, { - 'fields': ('fee_and_prizes', 'fee_and_prizes_enabled') + 'fields': ('fee_and_prizes', 'fee_and_prizes_enabled', 'fee_and_prizes_buttons') }), ) tab_accomodation = ( (None, { - 'fields': ('accomodation', 'accomodation_enabled') + 'fields': ('accomodation', 'accomodation_enabled', 'accomodation_buttons') }), ) tab_contact = ( (None, { - 'fields': ('contact', 'contact_enabled') + 'fields': ('contact', 'contact_enabled', 'contact_buttons') }), ) diff --git a/tournamentpages/migrations/0002_tournamentpage_accomodation_buttons_and_more.py b/tournamentpages/migrations/0002_tournamentpage_accomodation_buttons_and_more.py new file mode 100644 index 0000000..dce7600 --- /dev/null +++ b/tournamentpages/migrations/0002_tournamentpage_accomodation_buttons_and_more.py @@ -0,0 +1,43 @@ +# Generated by Django 4.0.5 on 2022-11-05 15:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tournamentpages', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='tournamentpage', + name='accomodation_buttons', + field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:

tekst1 -> link
tekst2 | link
...

Symbol -> oznacza, że link będzie otwarty w nowej karcie
Symbol | oznacza, że link będzie otwarty w tej samej karcie
Na przykład:

pzbs -> https://pzbs.pl
fotogaleria | https://galeria.podlaskizbs.pl
cezar -> https://www.msc.com.pl/cezar

PZBS i Cezar zostaną otwarte w nowej karcie
UWAGA !!
Klikając na zdjęcie zawsze zostaniemy przekierowani na pierwszy podany link
Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:

-> link do wyników
fotogaleria -> link do fotogalerii

Wtedy pokaże się tylko przycisk fotogalerii, a zdjęcie przekieruje nas do wyników!
', verbose_name='Przyciski'), + ), + migrations.AddField( + model_name='tournamentpage', + name='contact_buttons', + field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:

tekst1 -> link
tekst2 | link
...

Symbol -> oznacza, że link będzie otwarty w nowej karcie
Symbol | oznacza, że link będzie otwarty w tej samej karcie
Na przykład:

pzbs -> https://pzbs.pl
fotogaleria | https://galeria.podlaskizbs.pl
cezar -> https://www.msc.com.pl/cezar

PZBS i Cezar zostaną otwarte w nowej karcie
UWAGA !!
Klikając na zdjęcie zawsze zostaniemy przekierowani na pierwszy podany link
Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:

-> link do wyników
fotogaleria -> link do fotogalerii

Wtedy pokaże się tylko przycisk fotogalerii, a zdjęcie przekieruje nas do wyników!
', verbose_name='Przyciski'), + ), + migrations.AddField( + model_name='tournamentpage', + name='fee_and_prizes_buttons', + field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:

tekst1 -> link
tekst2 | link
...

Symbol -> oznacza, że link będzie otwarty w nowej karcie
Symbol | oznacza, że link będzie otwarty w tej samej karcie
Na przykład:

pzbs -> https://pzbs.pl
fotogaleria | https://galeria.podlaskizbs.pl
cezar -> https://www.msc.com.pl/cezar

PZBS i Cezar zostaną otwarte w nowej karcie
UWAGA !!
Klikając na zdjęcie zawsze zostaniemy przekierowani na pierwszy podany link
Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:

-> link do wyników
fotogaleria -> link do fotogalerii

Wtedy pokaże się tylko przycisk fotogalerii, a zdjęcie przekieruje nas do wyników!
', verbose_name='Przyciski'), + ), + migrations.AddField( + model_name='tournamentpage', + name='registration_buttons', + field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:

tekst1 -> link
tekst2 | link
...

Symbol -> oznacza, że link będzie otwarty w nowej karcie
Symbol | oznacza, że link będzie otwarty w tej samej karcie
Na przykład:

pzbs -> https://pzbs.pl
fotogaleria | https://galeria.podlaskizbs.pl
cezar -> https://www.msc.com.pl/cezar

PZBS i Cezar zostaną otwarte w nowej karcie
UWAGA !!
Klikając na zdjęcie zawsze zostaniemy przekierowani na pierwszy podany link
Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:

-> link do wyników
fotogaleria -> link do fotogalerii

Wtedy pokaże się tylko przycisk fotogalerii, a zdjęcie przekieruje nas do wyników!
', verbose_name='Przyciski'), + ), + migrations.AddField( + model_name='tournamentpage', + name='rules_buttons', + field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:

tekst1 -> link
tekst2 | link
...

Symbol -> oznacza, że link będzie otwarty w nowej karcie
Symbol | oznacza, że link będzie otwarty w tej samej karcie
Na przykład:

pzbs -> https://pzbs.pl
fotogaleria | https://galeria.podlaskizbs.pl
cezar -> https://www.msc.com.pl/cezar

PZBS i Cezar zostaną otwarte w nowej karcie
UWAGA !!
Klikając na zdjęcie zawsze zostaniemy przekierowani na pierwszy podany link
Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:

-> link do wyników
fotogaleria -> link do fotogalerii

Wtedy pokaże się tylko przycisk fotogalerii, a zdjęcie przekieruje nas do wyników!
', verbose_name='Przyciski'), + ), + migrations.AddField( + model_name='tournamentpage', + name='schedule_and_results_buttons', + field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:

tekst1 -> link
tekst2 | link
...

Symbol -> oznacza, że link będzie otwarty w nowej karcie
Symbol | oznacza, że link będzie otwarty w tej samej karcie
Na przykład:

pzbs -> https://pzbs.pl
fotogaleria | https://galeria.podlaskizbs.pl
cezar -> https://www.msc.com.pl/cezar

PZBS i Cezar zostaną otwarte w nowej karcie
UWAGA !!
Klikając na zdjęcie zawsze zostaniemy przekierowani na pierwszy podany link
Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:

-> link do wyników
fotogaleria -> link do fotogalerii

Wtedy pokaże się tylko przycisk fotogalerii, a zdjęcie przekieruje nas do wyników!
', verbose_name='Przyciski'), + ), + ] diff --git a/tournamentpages/migrations/0003_tournamentpage_homepage_buttons.py b/tournamentpages/migrations/0003_tournamentpage_homepage_buttons.py new file mode 100644 index 0000000..c4174da --- /dev/null +++ b/tournamentpages/migrations/0003_tournamentpage_homepage_buttons.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.5 on 2022-11-05 16:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tournamentpages', '0002_tournamentpage_accomodation_buttons_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='tournamentpage', + name='homepage_buttons', + field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:

tekst1 -> link
tekst2 | link
...

Symbol -> oznacza, że link będzie otwarty w nowej karcie
Symbol | oznacza, że link będzie otwarty w tej samej karcie
Na przykład:

pzbs -> https://pzbs.pl
fotogaleria | https://galeria.podlaskizbs.pl
cezar -> https://www.msc.com.pl/cezar

PZBS i Cezar zostaną otwarte w nowej karcie
UWAGA !!
Klikając na zdjęcie zawsze zostaniemy przekierowani na pierwszy podany link
Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:

-> link do wyników
fotogaleria -> link do fotogalerii

Wtedy pokaże się tylko przycisk fotogalerii, a zdjęcie przekieruje nas do wyników!
', verbose_name='Przyciski'), + ), + ] diff --git a/tournamentpages/models.py b/tournamentpages/models.py index 03c203e..ebf89dc 100644 --- a/tournamentpages/models.py +++ b/tournamentpages/models.py @@ -6,6 +6,31 @@ from tinymce.models import HTMLField # Create your models here. +buttons_help_text = """Tutaj można wpisać dowolną ilość przycisków w następującym formacie: + + tekst1 -> link + tekst2 | link + ... + + Symbol -> oznacza, że link będzie otwarty w nowej karcie + Symbol | oznacza, że link będzie otwarty w tej samej karcie + Na przykład: + + pzbs -> https://pzbs.pl + fotogaleria | https://galeria.podlaskizbs.pl + cezar -> https://www.msc.com.pl/cezar + + PZBS i Cezar zostaną otwarte w nowej karcie + UWAGA !! + Klikając na zdjęcie zawsze zostaniemy przekierowani na pierwszy podany link + Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób: + + -> link do wyników + fotogaleria -> link do fotogalerii + + Wtedy pokaże się tylko przycisk fotogalerii, a zdjęcie przekieruje nas do wyników! + """.replace('\n', '
') + class TournamentPage(models.Model): name = models.CharField('Nazwa', max_length=250) @@ -15,29 +40,43 @@ class TournamentPage(models.Model): footer = HTMLField('Stopka', default='', blank=True) homepage = HTMLField('Strona główna', default='', blank=True) + homepage_buttons = models.TextField( + 'Przyciski', default='', blank=True, help_text=buttons_help_text) schedule_and_results = HTMLField( 'Harmonogram i wyniki', default='', blank=True) schedule_and_results_enabled = models.BooleanField( 'Strona włączona', default=False) + schedule_and_results_buttons = models.TextField( + 'Przyciski', default='', blank=True, help_text=buttons_help_text) registration = HTMLField('Rejestracja', default='', blank=True) registration_enabled = models.BooleanField( 'Strona włączona', default=False) + registration_buttons = models.TextField( + 'Przyciski', default='', blank=True, help_text=buttons_help_text) rules = HTMLField('Regulamin', default='', blank=True) rules_enabled = models.BooleanField('Strona włączona', default=False) + rules_buttons = models.TextField( + 'Przyciski', default='', blank=True, help_text=buttons_help_text) fee_and_prizes = HTMLField('Wpisowe i nagrody', default='', blank=True) fee_and_prizes_enabled = models.BooleanField( 'Strona włączona', default=False) + fee_and_prizes_buttons = models.TextField( + 'Przyciski', default='', blank=True, help_text=buttons_help_text) accomodation = HTMLField('Noclegi', default='', blank=True) accomodation_enabled = models.BooleanField( 'Strona włączona', default=False) + accomodation_buttons = models.TextField( + 'Przyciski', default='', blank=True, help_text=buttons_help_text) contact = HTMLField('Kontakt', default='', blank=True) contact_enabled = models.BooleanField('Strona włączona', default=False) + contact_buttons = models.TextField( + 'Przyciski', default='', blank=True, help_text=buttons_help_text) class Meta: verbose_name = 'Strona turnieju' diff --git a/tournamentpages/templates/tournament.html b/tournamentpages/templates/tournament.html index dfb4c82..5829846 100644 --- a/tournamentpages/templates/tournament.html +++ b/tournamentpages/templates/tournament.html @@ -1,6 +1,6 @@ -{% load static tailwind_tags %} +{% load static tailwind_tags wysiwyg %} @@ -66,10 +66,13 @@ {% endif %} -
- {{ content | safe }} +
+
+ {{ content | safe }} +
+
{% buttons content_buttons %}
diff --git a/tournamentpages/views.py b/tournamentpages/views.py index 97cc9ca..7d2f098 100644 --- a/tournamentpages/views.py +++ b/tournamentpages/views.py @@ -10,7 +10,7 @@ class HomeView(TemplateView): def get_context_data(self, id, **kwargs): t = TournamentPage.objects.get(id=id, published=True) - return {'t': t, 'content': t.homepage, 'homepage': True} + return {'t': t, 'content': t.homepage, 'content_buttons': t.homepage_buttons, 'homepage': True} class ScheduleAndResultsView(TemplateView): @@ -19,7 +19,7 @@ class ScheduleAndResultsView(TemplateView): def get_context_data(self, id, **kwargs): t = TournamentPage.objects.get( id=id, published=True, schedule_and_results_enabled=True) - return {'t': t, 'content': t.schedule_and_results, 'schedule_and_results': True} + return {'t': t, 'content': t.schedule_and_results, 'content_buttons': t.schedule_and_results_buttons, 'schedule_and_results': True} class RegistrationView(TemplateView): @@ -28,7 +28,7 @@ class RegistrationView(TemplateView): def get_context_data(self, id, **kwargs): t = TournamentPage.objects.get( id=id, published=True, registration_enabled=True) - return {'t': t, 'content': t.registration, 'registration': True} + return {'t': t, 'content': t.registration, 'content_buttons': t.registration_buttons, 'registration': True} class RulesView(TemplateView): @@ -37,7 +37,7 @@ class RulesView(TemplateView): def get_context_data(self, id, **kwargs): t = TournamentPage.objects.get( id=id, published=True, rules_enabled=True) - return {'t': t, 'content': t.rules, 'rules': True} + return {'t': t, 'content': t.rules, 'content_buttons': t.rules_buttons, 'rules': True} class FeeAndPrizesView(TemplateView): @@ -46,7 +46,7 @@ class FeeAndPrizesView(TemplateView): def get_context_data(self, id, **kwargs): t = TournamentPage.objects.get( id=id, published=True, fee_and_prizes_enabled=True) - return {'t': t, 'content': t.fee_and_prizes, 'fee_and_prizes': True} + return {'t': t, 'content': t.fee_and_prizes, 'content_buttons': t.fee_and_prizes_buttons, 'fee_and_prizes': True} class AccomodationView(TemplateView): @@ -55,7 +55,7 @@ class AccomodationView(TemplateView): def get_context_data(self, id, **kwargs): t = TournamentPage.objects.get( id=id, published=True, accomodation_enabled=True) - return {'t': t, 'content': t.accomodation, 'accomodation': True} + return {'t': t, 'content': t.accomodation, 'content_buttons': t.accomodation_buttons, 'accomodation': True} class ContactView(TemplateView): @@ -64,4 +64,4 @@ class ContactView(TemplateView): def get_context_data(self, id, **kwargs): t = TournamentPage.objects.get( id=id, published=True, contact_enabled=True) - return {'t': t, 'content': t.contact, 'contact': True} + return {'t': t, 'content': t.contact, 'content_buttons': t.contact_buttons, 'contact': True}