from django.db import models from django.urls.base import reverse_lazy from django.utils.safestring import mark_safe 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) published = models.BooleanField('Turniej opublikowany', default=False) header = HTMLField('Nagłówek', default='', blank=True) 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' verbose_name_plural = 'Strony turniejów' @property def link(self): href = reverse_lazy('homepage', args=[self.id]) return mark_safe(f'{href}') def __str__(self): return self.name