68 lines
2.6 KiB
Python
68 lines
2.6 KiB
Python
from django.db import models
|
|
from django.urls.base import reverse_lazy
|
|
from django.utils.safestring import mark_safe
|
|
from tinymce.models import HTMLField
|
|
from admin_ordering.models import OrderableModel
|
|
from core.utils import SingletonModel
|
|
|
|
# Create your models here.
|
|
buttons_help_text = """Tutaj można wpisać dowolną ilość przycisków w następującym formacie:
|
|
<code>
|
|
tekst1 -> link
|
|
teskt2 | link
|
|
...
|
|
</code>
|
|
Symbol <code>-></code> oznacza, że link będzie otwarty w nowej karcie
|
|
Symbol <code>|</code> oznacza, że link będzie otwarty w tej samej karcie
|
|
Na przykład:
|
|
<code>
|
|
pzbs -> https://pzbs.pl
|
|
fotogaleria | https://galeria.podlaskizbs.pl
|
|
cezar -> https://www.msc.com.pl/cezar
|
|
</code>
|
|
PZBS i Cezar zostaną otwarte w nowej karcie
|
|
<b>UWAGA !!</b>
|
|
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:
|
|
<code>
|
|
-> link do wyników
|
|
fotogaleria -> link do fotogalerii
|
|
</code>
|
|
Wtedy pokaże się <b>tylko przycisk fotogalerii</b>, a zdjęcie przekieruje nas do wyników!
|
|
""".replace('\n', '<br />')
|
|
|
|
|
|
class Post(OrderableModel):
|
|
published = models.BooleanField('Wpis opublikowany', default=True)
|
|
show_title = models.BooleanField('Pokaż tytuł', default=True)
|
|
title = models.CharField('Tytuł', default='', blank=True, max_length=250)
|
|
content = HTMLField('Treść', default='', blank=True)
|
|
buttons = models.TextField(
|
|
'Przyciski', default='', blank=True, help_text=buttons_help_text)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
def __str__(self):
|
|
return self.title or '(brak tytułu)'
|
|
|
|
@property
|
|
def link(self):
|
|
href = reverse_lazy('home-reverse', args=[self.id])
|
|
return mark_safe(f'<a href="{href}" target="_blank">{href}</a>')
|
|
|
|
class Meta(OrderableModel.Meta):
|
|
verbose_name = 'Aktualność PodlZBS'
|
|
verbose_name_plural = 'Aktualności PodlZBS'
|
|
|
|
|
|
class GrandPrixW(SingletonModel):
|
|
content = HTMLField('Tekst GPW', default='', blank=True)
|
|
buttons = models.TextField(
|
|
'Przyciski', default='', blank=True, help_text=buttons_help_text)
|
|
|
|
def __str__(self):
|
|
return 'Grand Prix Województwa'
|
|
|
|
class Meta:
|
|
verbose_name = 'Grand Prix Województwa'
|
|
verbose_name_plural = 'Grand Prix Województwa'
|