change atu to orderable

main
yaemiku 2023-03-28 17:12:52 +02:00
parent 22619f71da
commit f3ec9505f2
Signed by: podlaskizbs
GPG Key ID: ADC039636B3E4AAB
39 changed files with 692 additions and 496 deletions

View File

@ -36,5 +36,5 @@ def load_config(request):
'memberships': Membership.objects.filter(published=True), 'memberships': Membership.objects.filter(published=True),
'youth': Youth.objects.filter(published=True), 'youth': Youth.objects.filter(published=True),
'mbkb': MBKB.objects.filter(published=True), 'mbkb': MBKB.objects.filter(published=True),
'atu': Atu.load() 'atus': Atu.objects.filter(published=True)
} }

View File

@ -3,12 +3,20 @@
{% block title %}ATU | pdlzbs{% endblock %} {% block title %}ATU | pdlzbs{% endblock %}
<!----> <!---->
{% load static tailwind_tags wysiwyg %} {% block content %} {% load static tailwind_tags wysiwyg %} {% block content %}
<div class="flex"> <div class="flex flex-col gap-4 items-center">
<article class="max-w-full mx-auto scrollable"> {% for atu in atus %}
{% content atu %} <article class="mx-auto max-w-full scrollable">
<div class="flex flex-wrap gap-4 items-center justify-center"> {% if atu.show_title %}
<h2 class="font-normal">{{ atu.title }}</h2>
{% endif %} {% content atu %}
<div class="flex flex-wrap gap-4 justify-center items-center">
{% buttons atu.buttons %} {% buttons atu.buttons %}
</div> </div>
</article> </article>
{% if not forloop.last %}
<hr class="w-36 border-b border-stone-200" />
{% endif %} {% empty %}
<span class="py-4 text-xl">Brak artykułów</span>
{% endfor %}
</div> </div>
{% endblock %} {% endblock %}

13
db/atu/admin.py 100644
View File

@ -0,0 +1,13 @@
from django.contrib import admin
from admin_ordering.admin import OrderableAdmin
from .models import *
# Register your models here.
@admin.register(Atu)
class AtuModelAdmin(OrderableAdmin, admin.ModelAdmin):
list_display = ['__str__', 'published', 'ordering']
list_editable = ['ordering']
ordering_field_hide_input = True
exclude = ['ordering']

View File

@ -0,0 +1,42 @@
# Generated by Django 4.1.7 on 2023-03-28 15:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('atu', '0003_atu_buttons'),
]
operations = [
migrations.AlterModelOptions(
name='atu',
options={'ordering': ['ordering'], 'verbose_name': 'Artykuł Stowarzyszenia Brydżowego ATU', 'verbose_name_plural': 'Artykuły Stowarzyszenia Brydżowego ATU'},
),
migrations.AddField(
model_name='atu',
name='ordering',
field=models.IntegerField(default=0, verbose_name='Kolejność'),
),
migrations.AddField(
model_name='atu',
name='published',
field=models.BooleanField(default=True, verbose_name='Wpis opublikowany'),
),
migrations.AddField(
model_name='atu',
name='show_title',
field=models.BooleanField(default=True, verbose_name='Pokaż tytuł'),
),
migrations.AddField(
model_name='atu',
name='title',
field=models.CharField(blank=True, default='', max_length=250, verbose_name='Tytuł'),
),
migrations.AlterField(
model_name='atu',
name='buttons',
field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:<br /> <code><br /> tekst1 -> link<br /> teskt2 | link<br /> ...<br /> </code><br /> Symbol <code>-></code> oznacza, że link będzie otwarty w nowej karcie<br /> Symbol <code>|</code> oznacza, że link będzie otwarty w tej samej karcie<br /> Na przykład:<br /> <code><br /> pzbs -> https://pzbs.pl<br /> fotogaleria | https://galeria.podlaskizbs.pl<br /> cezar -> https://www.msc.com.pl/cezar<br /> </code><br /> PZBS i Cezar zostaną otwarte w nowej karcie<br /> <b>UWAGA !!</b><br /> Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:<br /> <code><br /> -> link do wyników<br /> fotogaleria -> link do fotogalerii<br /> </code><br /> Wtedy pokaże się <b>tylko przycisk fotogalerii</b><br /> ', verbose_name='Przyciski'),
),
]

View File

@ -1,43 +1,24 @@
from django.db import models 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 tinymce.models import HTMLField
from core.utils import SingletonModel from admin_ordering.models import OrderableModel
from db.help import buttons_help_text
# Create your models here. # 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 Atu(OrderableModel):
class Atu(SingletonModel): 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('Tekst', default='', blank=True) content = HTMLField('Tekst', default='', blank=True)
buttons = models.TextField( buttons = models.TextField(
'Przyciski', default='', blank=True, help_text=buttons_help_text) 'Przyciski', default='', blank=True, help_text=buttons_help_text)
def __str__(self): def __str__(self):
return 'Stowarzyszenie Brydżowe ATU' return self.title or '-'
class Meta: class Meta(OrderableModel.Meta):
verbose_name = 'Stowarzyszenie Brydżowe ATU' verbose_name = 'Artykuł Stowarzyszenia Brydżowego ATU'
verbose_name_plural = 'Stowarzyszenie Brydżowe ATU' verbose_name_plural = 'Artykuły Stowarzyszenia Brydżowego ATU'

View File

@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-03-28 15:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('calendar', '0005_calendar_current'),
]
operations = [
migrations.AlterField(
model_name='calendar',
name='buttons',
field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:<br /> <code><br /> tekst1 -> link<br /> teskt2 | link<br /> ...<br /> </code><br /> Symbol <code>-></code> oznacza, że link będzie otwarty w nowej karcie<br /> Symbol <code>|</code> oznacza, że link będzie otwarty w tej samej karcie<br /> Na przykład:<br /> <code><br /> pzbs -> https://pzbs.pl<br /> fotogaleria | https://galeria.podlaskizbs.pl<br /> cezar -> https://www.msc.com.pl/cezar<br /> </code><br /> PZBS i Cezar zostaną otwarte w nowej karcie<br /> <b>UWAGA !!</b><br /> Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:<br /> <code><br /> -> link do wyników<br /> fotogaleria -> link do fotogalerii<br /> </code><br /> Wtedy pokaże się <b>tylko przycisk fotogalerii</b><br /> ', verbose_name='Przyciski'),
),
]

View File

@ -1,31 +1,8 @@
from django.db import models from django.db import models
from tinymce.models import HTMLField from tinymce.models import HTMLField
from db.help import buttons_help_text
# Create your models here. # 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 Calendar(models.Model): class Calendar(models.Model):

View File

@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-03-28 15:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('gpb', '0003_grandprixb_buttons'),
]
operations = [
migrations.AlterField(
model_name='grandprixb',
name='buttons',
field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:<br /> <code><br /> tekst1 -> link<br /> teskt2 | link<br /> ...<br /> </code><br /> Symbol <code>-></code> oznacza, że link będzie otwarty w nowej karcie<br /> Symbol <code>|</code> oznacza, że link będzie otwarty w tej samej karcie<br /> Na przykład:<br /> <code><br /> pzbs -> https://pzbs.pl<br /> fotogaleria | https://galeria.podlaskizbs.pl<br /> cezar -> https://www.msc.com.pl/cezar<br /> </code><br /> PZBS i Cezar zostaną otwarte w nowej karcie<br /> <b>UWAGA !!</b><br /> Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:<br /> <code><br /> -> link do wyników<br /> fotogaleria -> link do fotogalerii<br /> </code><br /> Wtedy pokaże się <b>tylko przycisk fotogalerii</b><br /> ', verbose_name='Przyciski'),
),
]

View File

@ -1,32 +1,9 @@
from django.db import models from django.db import models
from tinymce.models import HTMLField from tinymce.models import HTMLField
from core.utils import SingletonModel from core.utils import SingletonModel
from db.help import buttons_help_text
# Create your models here. # 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 GrandPrixB(SingletonModel): class GrandPrixB(SingletonModel):

24
db/help.py 100644
View File

@ -0,0 +1,24 @@
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>
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>
""".replace('\n', '<br />')

View File

@ -0,0 +1,27 @@
# Generated by Django 4.1.7 on 2023-03-28 15:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0007_remove_grandprixw_id_grandprixw_current_and_more'),
]
operations = [
migrations.AlterModelOptions(
name='grandprixw',
options={'ordering': ['-year'], 'verbose_name': 'Grand Prix Województwa', 'verbose_name_plural': 'Grand Prix Województwa'},
),
migrations.AlterField(
model_name='grandprixw',
name='buttons',
field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:<br /> <code><br /> tekst1 -> link<br /> teskt2 | link<br /> ...<br /> </code><br /> Symbol <code>-></code> oznacza, że link będzie otwarty w nowej karcie<br /> Symbol <code>|</code> oznacza, że link będzie otwarty w tej samej karcie<br /> Na przykład:<br /> <code><br /> pzbs -> https://pzbs.pl<br /> fotogaleria | https://galeria.podlaskizbs.pl<br /> cezar -> https://www.msc.com.pl/cezar<br /> </code><br /> PZBS i Cezar zostaną otwarte w nowej karcie<br /> <b>UWAGA !!</b><br /> Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:<br /> <code><br /> -> link do wyników<br /> fotogaleria -> link do fotogalerii<br /> </code><br /> Wtedy pokaże się <b>tylko przycisk fotogalerii</b><br /> ', verbose_name='Przyciski'),
),
migrations.AlterField(
model_name='post',
name='buttons',
field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:<br /> <code><br /> tekst1 -> link<br /> teskt2 | link<br /> ...<br /> </code><br /> Symbol <code>-></code> oznacza, że link będzie otwarty w nowej karcie<br /> Symbol <code>|</code> oznacza, że link będzie otwarty w tej samej karcie<br /> Na przykład:<br /> <code><br /> pzbs -> https://pzbs.pl<br /> fotogaleria | https://galeria.podlaskizbs.pl<br /> cezar -> https://www.msc.com.pl/cezar<br /> </code><br /> PZBS i Cezar zostaną otwarte w nowej karcie<br /> <b>UWAGA !!</b><br /> Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:<br /> <code><br /> -> link do wyników<br /> fotogaleria -> link do fotogalerii<br /> </code><br /> Wtedy pokaże się <b>tylko przycisk fotogalerii</b><br /> ', verbose_name='Przyciski'),
),
]

View File

@ -4,32 +4,9 @@ from django.utils.safestring import mark_safe
from tinymce.models import HTMLField from tinymce.models import HTMLField
from admin_ordering.models import OrderableModel from admin_ordering.models import OrderableModel
from core.utils import SingletonModel from core.utils import SingletonModel
from db.help import buttons_help_text
# Create your models here. # 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): class Post(OrderableModel):

View File

@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-03-28 15:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mbkb', '0002_mbkb_buttons'),
]
operations = [
migrations.AlterField(
model_name='mbkb',
name='buttons',
field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:<br /> <code><br /> tekst1 -> link<br /> teskt2 | link<br /> ...<br /> </code><br /> Symbol <code>-></code> oznacza, że link będzie otwarty w nowej karcie<br /> Symbol <code>|</code> oznacza, że link będzie otwarty w tej samej karcie<br /> Na przykład:<br /> <code><br /> pzbs -> https://pzbs.pl<br /> fotogaleria | https://galeria.podlaskizbs.pl<br /> cezar -> https://www.msc.com.pl/cezar<br /> </code><br /> PZBS i Cezar zostaną otwarte w nowej karcie<br /> <b>UWAGA !!</b><br /> Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:<br /> <code><br /> -> link do wyników<br /> fotogaleria -> link do fotogalerii<br /> </code><br /> Wtedy pokaże się <b>tylko przycisk fotogalerii</b><br /> ', verbose_name='Przyciski'),
),
]

View File

@ -1,34 +1,10 @@
from django.db import models from django.db import models
from tinymce.models import HTMLField from tinymce.models import HTMLField
from admin_ordering.models import OrderableModel from admin_ordering.models import OrderableModel
from db.help import buttons_help_text
# Create your models here. # 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 MBKB(OrderableModel): class MBKB(OrderableModel):
published = models.BooleanField('Wpis opublikowany', default=True) published = models.BooleanField('Wpis opublikowany', default=True)

View File

@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-03-28 15:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('membership', '0005_membership_current'),
]
operations = [
migrations.AlterField(
model_name='membership',
name='buttons',
field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:<br /> <code><br /> tekst1 -> link<br /> teskt2 | link<br /> ...<br /> </code><br /> Symbol <code>-></code> oznacza, że link będzie otwarty w nowej karcie<br /> Symbol <code>|</code> oznacza, że link będzie otwarty w tej samej karcie<br /> Na przykład:<br /> <code><br /> pzbs -> https://pzbs.pl<br /> fotogaleria | https://galeria.podlaskizbs.pl<br /> cezar -> https://www.msc.com.pl/cezar<br /> </code><br /> PZBS i Cezar zostaną otwarte w nowej karcie<br /> <b>UWAGA !!</b><br /> Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:<br /> <code><br /> -> link do wyników<br /> fotogaleria -> link do fotogalerii<br /> </code><br /> Wtedy pokaże się <b>tylko przycisk fotogalerii</b><br /> ', verbose_name='Przyciski'),
),
]

View File

@ -1,32 +1,9 @@
from django.db import models from django.db import models
from tinymce.models import HTMLField from tinymce.models import HTMLField
from db.help import buttons_help_text
# Create your models here. # 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 Membership(models.Model): class Membership(models.Model):

View File

@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-03-28 15:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tournaments', '0007_alter_tournament_buttons'),
]
operations = [
migrations.AlterField(
model_name='tournament',
name='buttons',
field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:<br /> <code><br /> tekst1 -> link<br /> teskt2 | link<br /> ...<br /> </code><br /> Symbol <code>-></code> oznacza, że link będzie otwarty w nowej karcie<br /> Symbol <code>|</code> oznacza, że link będzie otwarty w tej samej karcie<br /> Na przykład:<br /> <code><br /> pzbs -> https://pzbs.pl<br /> fotogaleria | https://galeria.podlaskizbs.pl<br /> cezar -> https://www.msc.com.pl/cezar<br /> </code><br /> PZBS i Cezar zostaną otwarte w nowej karcie<br /> <b>UWAGA !!</b><br /> Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:<br /> <code><br /> -> link do wyników<br /> fotogaleria -> link do fotogalerii<br /> </code><br /> Wtedy pokaże się <b>tylko przycisk fotogalerii</b><br /> ', verbose_name='Przyciski'),
),
]

View File

@ -4,33 +4,10 @@ from django.utils.safestring import mark_safe
from admin_ordering.models import OrderableModel from admin_ordering.models import OrderableModel
from tinymce.models import HTMLField from tinymce.models import HTMLField
from filebrowser.fields import FileBrowseField from filebrowser.fields import FileBrowseField
from db.help import buttons_help_text
# Create your models here. # 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 Tournament(OrderableModel): class Tournament(OrderableModel):

View File

@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-03-28 15:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('youth', '0004_alter_youth_buttons'),
]
operations = [
migrations.AlterField(
model_name='youth',
name='buttons',
field=models.TextField(blank=True, default='', help_text='Tutaj można wpisać dowolną ilość przycisków w następującym formacie:<br /> <code><br /> tekst1 -> link<br /> teskt2 | link<br /> ...<br /> </code><br /> Symbol <code>-></code> oznacza, że link będzie otwarty w nowej karcie<br /> Symbol <code>|</code> oznacza, że link będzie otwarty w tej samej karcie<br /> Na przykład:<br /> <code><br /> pzbs -> https://pzbs.pl<br /> fotogaleria | https://galeria.podlaskizbs.pl<br /> cezar -> https://www.msc.com.pl/cezar<br /> </code><br /> PZBS i Cezar zostaną otwarte w nowej karcie<br /> <b>UWAGA !!</b><br /> Gdy nie podamy tekstu przyciku, nie pokaże on się, można to wykorzystać w taki sposób:<br /> <code><br /> -> link do wyników<br /> fotogaleria -> link do fotogalerii<br /> </code><br /> Wtedy pokaże się <b>tylko przycisk fotogalerii</b><br /> ', verbose_name='Przyciski'),
),
]

View File

@ -3,27 +3,10 @@ from django.urls.base import reverse_lazy
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from tinymce.models import HTMLField from tinymce.models import HTMLField
from admin_ordering.models import OrderableModel from admin_ordering.models import OrderableModel
from db.help import buttons_help_text
# Create your models here. # 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
""".replace('\n', '<br />')
class Youth(OrderableModel): class Youth(OrderableModel):
published = models.BooleanField('Wpis opublikowany', default=True) published = models.BooleanField('Wpis opublikowany', default=True)

View File

@ -5,3 +5,5 @@ django-tinymce
django-filebrowser-no-grappelli django-filebrowser-no-grappelli
django-htmlmin django-htmlmin
django-cleanup django-cleanup
django-js-asset
pillow

View File

@ -57,40 +57,6 @@
--object-tools-hover-bg: var(--close-button-hover-bg); --object-tools-hover-bg: var(--close-button-hover-bg);
} }
@media (prefers-color-scheme: dark) {
:root {
--primary: #264b5d;
--primary-fg: #eee;
--body-fg: #eeeeee;
--body-bg: #121212;
--body-quiet-color: #e0e0e0;
--body-loud-color: #ffffff;
--breadcrumbs-link-fg: #e0e0e0;
--breadcrumbs-bg: var(--primary);
--link-fg: #81d4fa;
--link-hover-color: #4ac1f7;
--link-selected-fg: #6f94c6;
--hairline-color: #272727;
--border-color: #353535;
--error-fg: #e35f5f;
--message-success-bg: #006b1b;
--message-warning-bg: #583305;
--message-error-bg: #570808;
--darkened-bg: #212121;
--selected-bg: #1b1b1b;
--selected-row: #00363a;
--close-button-bg: #333333;
--close-button-hover-bg: #666666;
}
}
html, body { html, body {
height: 100%; height: 100%;
} }
@ -98,7 +64,7 @@ html, body {
body { body {
margin: 0; margin: 0;
padding: 0; padding: 0;
font-size: 14px; font-size: 0.875rem;
font-family: "Roboto","Lucida Grande","DejaVu Sans","Bitstream Vera Sans",Verdana,Arial,sans-serif; font-family: "Roboto","Lucida Grande","DejaVu Sans","Bitstream Vera Sans",Verdana,Arial,sans-serif;
color: var(--body-fg); color: var(--body-fg);
background: var(--body-bg); background: var(--body-bg);
@ -151,12 +117,12 @@ h1,h2,h3,h4,h5 {
h1 { h1 {
margin: 0 0 20px; margin: 0 0 20px;
font-weight: 300; font-weight: 300;
font-size: 20px; font-size: 1.25rem;
color: var(--body-quiet-color); color: var(--body-quiet-color);
} }
h2 { h2 {
font-size: 16px; font-size: 1rem;
margin: 1em 0 .5em 0; margin: 1em 0 .5em 0;
} }
@ -166,20 +132,20 @@ h2.subhead {
} }
h3 { h3 {
font-size: 14px; font-size: 0.875rem;
margin: .8em 0 .3em 0; margin: .8em 0 .3em 0;
color: var(--body-quiet-color); color: var(--body-quiet-color);
font-weight: bold; font-weight: bold;
} }
h4 { h4 {
font-size: 12px; font-size: 0.75rem;
margin: 1em 0 .8em 0; margin: 1em 0 .8em 0;
padding-bottom: 3px; padding-bottom: 3px;
} }
h5 { h5 {
font-size: 10px; font-size: 0.625rem;
margin: 1.5em 0 .5em 0; margin: 1.5em 0 .5em 0;
color: var(--body-quiet-color); color: var(--body-quiet-color);
text-transform: uppercase; text-transform: uppercase;
@ -196,7 +162,7 @@ li ul {
} }
li, dt, dd { li, dt, dd {
font-size: 13px; font-size: 0.8125rem;
line-height: 20px; line-height: 20px;
} }
@ -223,7 +189,7 @@ fieldset {
} }
blockquote { blockquote {
font-size: 11px; font-size: 0.6875rem;
color: #777; color: #777;
margin-left: 2px; margin-left: 2px;
padding-left: 10px; padding-left: 10px;
@ -233,7 +199,7 @@ blockquote {
code, pre { code, pre {
font-family: "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace; font-family: "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace;
color: var(--body-quiet-color); color: var(--body-quiet-color);
font-size: 12px; font-size: 0.75rem;
overflow-x: auto; overflow-x: auto;
} }
@ -255,22 +221,21 @@ hr {
border: none; border: none;
margin: 0; margin: 0;
padding: 0; padding: 0;
font-size: 1px;
line-height: 1px; line-height: 1px;
} }
/* TEXT STYLES & MODIFIERS */ /* TEXT STYLES & MODIFIERS */
.small { .small {
font-size: 11px; font-size: 0.6875rem;
} }
.mini { .mini {
font-size: 10px; font-size: 0.625rem;
} }
.help, p.help, form p.help, div.help, form div.help, div.help li { .help, p.help, form p.help, div.help, form div.help, div.help li {
font-size: 11px; font-size: 0.6875rem;
color: var(--body-quiet-color); color: var(--body-quiet-color);
} }
@ -300,7 +265,7 @@ p img, h1 img, h2 img, h3 img, h4 img, td img {
} }
.hidden { .hidden {
display: none; display: none !important;
} }
/* TABLES */ /* TABLES */
@ -311,7 +276,7 @@ table {
} }
td, th { td, th {
font-size: 13px; font-size: 0.8125rem;
line-height: 16px; line-height: 16px;
border-bottom: 1px solid var(--hairline-color); border-bottom: 1px solid var(--hairline-color);
vertical-align: top; vertical-align: top;
@ -327,7 +292,7 @@ thead th,
tfoot td { tfoot td {
color: var(--body-quiet-color); color: var(--body-quiet-color);
padding: 5px 10px; padding: 5px 10px;
font-size: 11px; font-size: 0.6875rem;
background: var(--body-bg); background: var(--body-bg);
border: none; border: none;
border-top: 1px solid var(--hairline-color); border-top: 1px solid var(--hairline-color);
@ -437,7 +402,7 @@ table thead th.sorted .sortoptions a.sortremove:after {
top: -6px; top: -6px;
left: 3px; left: 3px;
font-weight: 200; font-weight: 200;
font-size: 18px; font-size: 1.125rem;
color: var(--body-quiet-color); color: var(--body-quiet-color);
} }
@ -478,7 +443,7 @@ input, textarea, select, .form-row p, form .button {
vertical-align: middle; vertical-align: middle;
font-family: "Roboto", "Lucida Grande", Verdana, Arial, sans-serif; font-family: "Roboto", "Lucida Grande", Verdana, Arial, sans-serif;
font-weight: normal; font-weight: normal;
font-size: 13px; font-size: 0.8125rem;
} }
.form-row div.help { .form-row div.help {
padding: 2px 3px; padding: 2px 3px;
@ -589,7 +554,7 @@ input[type=button][disabled].default {
margin: 0; margin: 0;
padding: 8px; padding: 8px;
font-weight: 400; font-weight: 400;
font-size: 13px; font-size: 0.8125rem;
text-align: left; text-align: left;
background: var(--primary); background: var(--primary);
color: var(--header-link-color); color: var(--header-link-color);
@ -597,7 +562,7 @@ input[type=button][disabled].default {
.module caption, .module caption,
.inline-group h2 { .inline-group h2 {
font-size: 12px; font-size: 0.75rem;
letter-spacing: 0.5px; letter-spacing: 0.5px;
text-transform: uppercase; text-transform: uppercase;
} }
@ -616,12 +581,13 @@ ul.messagelist {
ul.messagelist li { ul.messagelist li {
display: block; display: block;
font-weight: 400; font-weight: 400;
font-size: 13px; font-size: 0.8125rem;
padding: 10px 10px 10px 65px; padding: 10px 10px 10px 65px;
margin: 0 0 10px 0; margin: 0 0 10px 0;
background: var(--message-success-bg) url(../img/icon-yes.svg) 40px 12px no-repeat; background: var(--message-success-bg) url(../img/icon-yes.svg) 40px 12px no-repeat;
background-size: 16px auto; background-size: 16px auto;
color: var(--body-fg); color: var(--body-fg);
word-break: break-word;
} }
ul.messagelist li.warning { ul.messagelist li.warning {
@ -635,7 +601,7 @@ ul.messagelist li.error {
} }
.errornote { .errornote {
font-size: 14px; font-size: 0.875rem;
font-weight: 700; font-weight: 700;
display: block; display: block;
padding: 10px 12px; padding: 10px 12px;
@ -656,7 +622,7 @@ ul.errorlist {
} }
ul.errorlist li { ul.errorlist li {
font-size: 13px; font-size: 0.8125rem;
display: block; display: block;
margin-bottom: 4px; margin-bottom: 4px;
overflow-wrap: break-word; overflow-wrap: break-word;
@ -697,7 +663,7 @@ td ul.errorlist + input, td ul.errorlist + select, td ul.errorlist + textarea {
} }
.description { .description {
font-size: 12px; font-size: 0.75rem;
padding: 5px 0 0 12px; padding: 5px 0 0 12px;
} }
@ -753,7 +719,7 @@ a.deletelink:focus, a.deletelink:hover {
/* OBJECT TOOLS */ /* OBJECT TOOLS */
.object-tools { .object-tools {
font-size: 10px; font-size: 0.625rem;
font-weight: bold; font-weight: bold;
padding-left: 0; padding-left: 0;
float: right; float: right;
@ -779,7 +745,7 @@ a.deletelink:focus, a.deletelink:hover {
background: var(--object-tools-bg); background: var(--object-tools-bg);
color: var(--object-tools-fg); color: var(--object-tools-fg);
font-weight: 400; font-weight: 400;
font-size: 11px; font-size: 0.6875rem;
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 0.5px; letter-spacing: 0.5px;
} }
@ -808,14 +774,21 @@ a.deletelink:focus, a.deletelink:hover {
/* OBJECT HISTORY */ /* OBJECT HISTORY */
table#change-history { #change-history table {
width: 100%; width: 100%;
} }
table#change-history tbody th { #change-history table tbody th {
width: 16em; width: 16em;
} }
#change-history .paginator {
color: var(--body-quiet-color);
border-bottom: 1px solid var(--hairline-color);
background: var(--body-bg);
overflow: hidden;
}
/* PAGE STRUCTURE */ /* PAGE STRUCTURE */
#container { #container {
@ -905,7 +878,7 @@ table#change-history tbody th {
overflow: hidden; overflow: hidden;
} }
#header a:link, #header a:visited { #header a:link, #header a:visited, #logout-form button {
color: var(--header-link-color); color: var(--header-link-color);
} }
@ -921,17 +894,17 @@ table#change-history tbody th {
padding: 0; padding: 0;
margin: 0 20px 0 0; margin: 0 20px 0 0;
font-weight: 300; font-weight: 300;
font-size: 24px; font-size: 1.5rem;
color: var(--accent); color: var(--header-branding-color);
} }
#branding h1, #branding h1 a:link, #branding h1 a:visited { #branding h1 a:link, #branding h1 a:visited {
color: var(--accent); color: var(--accent);
} }
#branding h2 { #branding h2 {
padding: 0 10px; padding: 0 10px;
font-size: 14px; font-size: 0.875rem;
margin: -8px 0 8px 0; margin: -8px 0 8px 0;
font-weight: normal; font-weight: normal;
color: var(--header-color); color: var(--header-color);
@ -941,25 +914,43 @@ table#change-history tbody th {
text-decoration: none; text-decoration: none;
} }
#logout-form {
display: inline;
}
#logout-form button {
background: none;
border: 0;
cursor: pointer;
font-family: "Roboto","Lucida Grande","DejaVu Sans","Bitstream Vera Sans",Verdana,Arial,sans-serif;
}
#user-tools { #user-tools {
float: right; float: right;
padding: 0;
margin: 0 0 0 20px; margin: 0 0 0 20px;
font-weight: 300;
font-size: 11px;
letter-spacing: 0.5px;
text-transform: uppercase;
text-align: right; text-align: right;
} }
#user-tools a { #user-tools, #logout-form button{
padding: 0;
font-weight: 300;
font-size: 0.6875rem;
letter-spacing: 0.5px;
text-transform: uppercase;
}
#user-tools a, #logout-form button {
border-bottom: 1px solid rgba(255, 255, 255, 0.25); border-bottom: 1px solid rgba(255, 255, 255, 0.25);
} }
#user-tools a:focus, #user-tools a:hover { #user-tools a:focus, #user-tools a:hover,
#logout-form button:active, #logout-form button:hover {
text-decoration: none; text-decoration: none;
border-bottom-color: var(--primary); border-bottom: 0;
color: var(--primary); }
#logout-form button:active, #logout-form button:hover {
margin-bottom: 1px;
} }
/* SIDEBAR */ /* SIDEBAR */
@ -979,7 +970,7 @@ table#change-history tbody th {
} }
#content-related h4 { #content-related h4 {
font-size: 13px; font-size: 0.8125rem;
} }
#content-related p { #content-related p {
@ -1003,7 +994,7 @@ table#change-history tbody th {
padding: 16px; padding: 16px;
margin-bottom: 16px; margin-bottom: 16px;
border-bottom: 1px solid var(--hairline-color); border-bottom: 1px solid var(--hairline-color);
font-size: 18px; font-size: 1.125rem;
color: var(--body-fg); color: var(--body-fg);
} }
@ -1050,3 +1041,49 @@ table#change-history tbody th {
.popup #header { .popup #header {
padding: 10px 20px; padding: 10px 20px;
} }
/* PAGINATOR */
.paginator {
font-size: 0.8125rem;
padding-top: 10px;
padding-bottom: 10px;
line-height: 22px;
margin: 0;
border-top: 1px solid var(--hairline-color);
width: 100%;
}
.paginator a:link, .paginator a:visited {
padding: 2px 6px;
background: var(--button-bg);
text-decoration: none;
color: var(--button-fg);
}
.paginator a.showall {
border: none;
background: none;
color: var(--link-fg);
}
.paginator a.showall:focus, .paginator a.showall:hover {
background: none;
color: var(--link-hover-color);
}
.paginator .end {
margin-right: 6px;
}
.paginator .this-page {
padding: 2px 6px;
font-weight: bold;
font-size: 0.8125rem;
vertical-align: top;
}
.paginator a:focus, .paginator a:hover {
color: white;
background: var(--link-hover-color);
}

View File

@ -84,7 +84,7 @@
#toolbar form input { #toolbar form input {
border-radius: 4px; border-radius: 4px;
font-size: 14px; font-size: 0.875rem;
padding: 5px; padding: 5px;
color: var(--body-fg); color: var(--body-fg);
} }
@ -95,7 +95,7 @@
padding: 2px 5px; padding: 2px 5px;
margin: 0; margin: 0;
vertical-align: top; vertical-align: top;
font-size: 13px; font-size: 0.8125rem;
max-width: 100%; max-width: 100%;
} }
@ -105,7 +105,7 @@
#toolbar form input[type="submit"] { #toolbar form input[type="submit"] {
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
font-size: 13px; font-size: 0.8125rem;
padding: 4px 8px; padding: 4px 8px;
margin: 0; margin: 0;
vertical-align: middle; vertical-align: middle;
@ -140,7 +140,7 @@
} }
#changelist-filter h2 { #changelist-filter h2 {
font-size: 14px; font-size: 0.875rem;
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 0.5px; letter-spacing: 0.5px;
padding: 5px 15px; padding: 5px 15px;
@ -148,12 +148,35 @@
border-bottom: none; border-bottom: none;
} }
#changelist-filter h3 { #changelist-filter h3,
#changelist-filter details summary {
font-weight: 400; font-weight: 400;
padding: 0 15px; padding: 0 15px;
margin-bottom: 10px; margin-bottom: 10px;
} }
#changelist-filter details summary > * {
display: inline;
}
#changelist-filter details > summary {
list-style-type: none;
}
#changelist-filter details > summary::-webkit-details-marker {
display: none;
}
#changelist-filter details > summary::before {
content: '→';
font-weight: bold;
color: var(--link-hover-color);
}
#changelist-filter details[open] > summary::before {
content: '↓';
}
#changelist-filter ul { #changelist-filter ul {
margin: 5px 0; margin: 5px 0;
padding: 0 15px 15px; padding: 0 15px 15px;
@ -173,8 +196,7 @@
#changelist-filter a { #changelist-filter a {
display: block; display: block;
color: var(--body-quiet-color); color: var(--body-quiet-color);
text-overflow: ellipsis; word-break: break-word;
overflow-x: hidden;
} }
#changelist-filter li.selected { #changelist-filter li.selected {
@ -194,7 +216,7 @@
} }
#changelist-filter #changelist-filter-clear a { #changelist-filter #changelist-filter-clear a {
font-size: 13px; font-size: 0.8125rem;
padding-bottom: 10px; padding-bottom: 10px;
border-bottom: 1px solid var(--hairline-color); border-bottom: 1px solid var(--hairline-color);
} }
@ -225,52 +247,6 @@
color: var(--link-hover-color); color: var(--link-hover-color);
} }
/* PAGINATOR */
.paginator {
font-size: 13px;
padding-top: 10px;
padding-bottom: 10px;
line-height: 22px;
margin: 0;
border-top: 1px solid var(--hairline-color);
width: 100%;
}
.paginator a:link, .paginator a:visited {
padding: 2px 6px;
background: var(--button-bg);
text-decoration: none;
color: var(--button-fg);
}
.paginator a.showall {
border: none;
background: none;
color: var(--link-fg);
}
.paginator a.showall:focus, .paginator a.showall:hover {
background: none;
color: var(--link-hover-color);
}
.paginator .end {
margin-right: 6px;
}
.paginator .this-page {
padding: 2px 6px;
font-weight: bold;
font-size: 13px;
vertical-align: top;
}
.paginator a:focus, .paginator a:hover {
color: white;
background: var(--link-hover-color);
}
/* ACTIONS */ /* ACTIONS */
.filtered .actions { .filtered .actions {
@ -296,17 +272,11 @@
width: 100%; width: 100%;
} }
#changelist .actions.selected { /* XXX Probably unused? */
background: var(--body-bg);
border-top: 1px solid var(--body-bg);
border-bottom: 1px solid #edecd6;
}
#changelist .actions span.all, #changelist .actions span.all,
#changelist .actions span.action-counter, #changelist .actions span.action-counter,
#changelist .actions span.clear, #changelist .actions span.clear,
#changelist .actions span.question { #changelist .actions span.question {
font-size: 13px; font-size: 0.8125rem;
margin: 0 0.5em; margin: 0 0.5em;
} }
@ -320,7 +290,7 @@
color: var(--body-fg); color: var(--body-fg);
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
border-radius: 4px; border-radius: 4px;
font-size: 14px; font-size: 0.875rem;
padding: 0 0 0 4px; padding: 0 0 0 4px;
margin: 0; margin: 0;
margin-left: 10px; margin-left: 10px;
@ -333,11 +303,11 @@
#changelist .actions label { #changelist .actions label {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
font-size: 13px; font-size: 0.8125rem;
} }
#changelist .actions .button { #changelist .actions .button {
font-size: 13px; font-size: 0.8125rem;
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
border-radius: 4px; border-radius: 4px;
background: var(--body-bg); background: var(--body-bg);

View File

@ -0,0 +1,33 @@
@media (prefers-color-scheme: dark) {
:root {
--primary: #264b5d;
--primary-fg: #f7f7f7;
--body-fg: #eeeeee;
--body-bg: #121212;
--body-quiet-color: #e0e0e0;
--body-loud-color: #ffffff;
--breadcrumbs-link-fg: #e0e0e0;
--breadcrumbs-bg: var(--primary);
--link-fg: #81d4fa;
--link-hover-color: #4ac1f7;
--link-selected-fg: #6f94c6;
--hairline-color: #272727;
--border-color: #353535;
--error-fg: #e35f5f;
--message-success-bg: #006b1b;
--message-warning-bg: #583305;
--message-error-bg: #570808;
--darkened-bg: #212121;
--selected-bg: #1b1b1b;
--selected-row: #00363a;
--close-button-bg: #333333;
--close-button-hover-bg: #666666;
}
}

View File

@ -5,7 +5,7 @@
.form-row { .form-row {
overflow: hidden; overflow: hidden;
padding: 10px; padding: 10px;
font-size: 13px; font-size: 0.8125rem;
border-bottom: 1px solid var(--hairline-color); border-bottom: 1px solid var(--hairline-color);
} }
@ -27,7 +27,7 @@ form .form-row p {
label { label {
font-weight: normal; font-weight: normal;
color: var(--body-quiet-color); color: var(--body-quiet-color);
font-size: 13px; font-size: 0.8125rem;
} }
.required label, label.required { .required label, label.required {
@ -248,7 +248,7 @@ fieldset.monospace textarea {
/* SUBMIT ROW */ /* SUBMIT ROW */
.submit-row { .submit-row {
padding: 12px 14px; padding: 12px 14px 7px;
margin: 0 0 20px; margin: 0 0 20px;
background: var(--darkened-bg); background: var(--darkened-bg);
border: 1px solid var(--hairline-color); border: 1px solid var(--hairline-color);
@ -264,11 +264,11 @@ body.popup .submit-row {
.submit-row input { .submit-row input {
height: 35px; height: 35px;
line-height: 15px; line-height: 15px;
margin: 0 0 0 5px; margin: 0 0 5px 5px;
} }
.submit-row input.default { .submit-row input.default {
margin: 0 0 0 8px; margin: 0 0 5px 8px;
text-transform: uppercase; text-transform: uppercase;
} }
@ -288,6 +288,7 @@ body.popup .submit-row {
padding: 10px 15px; padding: 10px 15px;
height: 15px; height: 15px;
line-height: 15px; line-height: 15px;
margin-bottom: 5px;
color: var(--button-fg); color: var(--button-fg);
} }
@ -353,10 +354,6 @@ body.popup .submit-row {
width: 2.2em; width: 2.2em;
} }
.vTextField, .vUUIDField {
width: 20em;
}
.vIntegerField { .vIntegerField {
width: 5em; width: 5em;
} }
@ -369,6 +366,10 @@ body.popup .submit-row {
width: 5em; width: 5em;
} }
.vTextField, .vUUIDField {
width: 20em;
}
/* INLINES */ /* INLINES */
.inline-group { .inline-group {
@ -392,7 +393,7 @@ body.popup .submit-row {
margin: 0; margin: 0;
color: var(--body-quiet-color); color: var(--body-quiet-color);
padding: 5px; padding: 5px;
font-size: 13px; font-size: 0.8125rem;
background: var(--darkened-bg); background: var(--darkened-bg);
border-top: 1px solid var(--hairline-color); border-top: 1px solid var(--hairline-color);
border-bottom: 1px solid var(--hairline-color); border-bottom: 1px solid var(--hairline-color);
@ -404,7 +405,7 @@ body.popup .submit-row {
.inline-related h3 span.delete label { .inline-related h3 span.delete label {
margin-left: 2px; margin-left: 2px;
font-size: 11px; font-size: 0.6875rem;
} }
.inline-related fieldset { .inline-related fieldset {
@ -417,7 +418,7 @@ body.popup .submit-row {
.inline-related fieldset.module h3 { .inline-related fieldset.module h3 {
margin: 0; margin: 0;
padding: 2px 5px 3px 5px; padding: 2px 5px 3px 5px;
font-size: 11px; font-size: 0.6875rem;
text-align: left; text-align: left;
font-weight: bold; font-weight: bold;
background: #bcd; background: #bcd;
@ -458,7 +459,7 @@ body.popup .submit-row {
height: 1.1em; height: 1.1em;
padding: 2px 9px; padding: 2px 9px;
overflow: hidden; overflow: hidden;
font-size: 9px; font-size: 0.5625rem;
font-weight: bold; font-weight: bold;
color: var(--body-quiet-color); color: var(--body-quiet-color);
_width: 700px; _width: 700px;
@ -493,7 +494,7 @@ body.popup .submit-row {
.inline-group .tabular tr.add-row td a { .inline-group .tabular tr.add-row td a {
background: url(../img/icon-addlink.svg) 0 1px no-repeat; background: url(../img/icon-addlink.svg) 0 1px no-repeat;
padding-left: 16px; padding-left: 16px;
font-size: 12px; font-size: 0.75rem;
} }
.empty-form { .empty-form {

View File

@ -12,7 +12,7 @@
} }
.login #header h1 { .login #header h1 {
font-size: 18px; font-size: 1.125rem;
margin: 0; margin: 0;
} }

View File

@ -16,7 +16,7 @@
border-right: 1px solid var(--hairline-color); border-right: 1px solid var(--hairline-color);
background-color: var(--body-bg); background-color: var(--body-bg);
cursor: pointer; cursor: pointer;
font-size: 20px; font-size: 1.25rem;
color: var(--link-fg); color: var(--link-fg);
padding: 0; padding: 0;
} }

View File

@ -14,11 +14,11 @@ input[type="submit"], button {
td, th { td, th {
padding: 10px; padding: 10px;
font-size: 14px; font-size: 0.875rem;
} }
.small { .small {
font-size: 12px; font-size: 0.75rem;
} }
/* Layout */ /* Layout */
@ -28,7 +28,7 @@ input[type="submit"], button {
} }
#content { #content {
padding: 20px 30px 30px; padding: 15px 20px 20px;
} }
div.breadcrumbs { div.breadcrumbs {
@ -45,7 +45,6 @@ input[type="submit"], button {
#branding h1 { #branding h1 {
margin: 0 0 8px; margin: 0 0 8px;
font-size: 20px;
line-height: 1.2; line-height: 1.2;
} }
@ -88,7 +87,7 @@ input[type="submit"], button {
} }
td .changelink, td .addlink { td .changelink, td .addlink {
font-size: 13px; font-size: 0.8125rem;
} }
/* Changelist */ /* Changelist */
@ -131,10 +130,6 @@ input[type="submit"], button {
padding: 15px 0; padding: 15px 0;
} }
#changelist .actions.selected {
border: none;
}
#changelist .actions label { #changelist .actions label {
display: flex; display: flex;
} }
@ -152,7 +147,7 @@ input[type="submit"], button {
#changelist .actions span.clear, #changelist .actions span.clear,
#changelist .actions span.question, #changelist .actions span.question,
#changelist .actions span.action-counter { #changelist .actions span.action-counter {
font-size: 11px; font-size: 0.6875rem;
margin: 0 10px 0 0; margin: 0 10px 0 0;
} }
@ -176,7 +171,7 @@ input[type="submit"], button {
/* Forms */ /* Forms */
label { label {
font-size: 14px; font-size: 0.875rem;
} }
.form-row input[type=text], .form-row input[type=text],
@ -192,7 +187,7 @@ input[type="submit"], button {
margin: 0; margin: 0;
padding: 6px 8px; padding: 6px 8px;
min-height: 36px; min-height: 36px;
font-size: 14px; font-size: 0.875rem;
} }
.form-row select { .form-row select {
@ -236,6 +231,22 @@ input[type="submit"], button {
margin-left: 2px; margin-left: 2px;
} }
.submit-row {
padding: 8px 8px 3px 8px;
}
.submit-row a.deletelink {
padding: 10px 7px;
}
.submit-row input.default {
margin: 0 0 5px 5px;
}
.button, input[type=submit], input[type=button], .submit-row input, a.button {
padding: 7px;
}
/* Related widget */ /* Related widget */
.related-widget-wrapper { .related-widget-wrapper {
@ -393,12 +404,12 @@ input[type="submit"], button {
} }
.datetime span { .datetime span {
font-size: 13px; font-size: 0.8125rem;
} }
.datetime .timezonewarning { .datetime .timezonewarning {
display: block; display: block;
font-size: 11px; font-size: 0.6875rem;
color: var(--body-quiet-color); color: var(--body-quiet-color);
} }
@ -496,7 +507,7 @@ input[type="submit"], button {
#content-related .module h2 { #content-related .module h2 {
padding: 10px 15px; padding: 10px 15px;
font-size: 16px; font-size: 1rem;
} }
/* Changelist */ /* Changelist */
@ -622,7 +633,7 @@ input[type="submit"], button {
.aligned p.file-upload { .aligned p.file-upload {
margin-left: 0; margin-left: 0;
font-size: 13px; font-size: 0.8125rem;
} }
span.clearable-file-input { span.clearable-file-input {
@ -630,7 +641,7 @@ input[type="submit"], button {
} }
span.clearable-file-input label { span.clearable-file-input label {
font-size: 13px; font-size: 0.8125rem;
padding-bottom: 0; padding-bottom: 0;
} }
@ -812,7 +823,7 @@ input[type="submit"], button {
/* Submit row */ /* Submit row */
.submit-row { .submit-row {
padding: 10px 10px 0; padding: 10px 10px 5px;
margin: 0 0 15px; margin: 0 0 15px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -907,7 +918,7 @@ input[type="submit"], button {
.errornote { .errornote {
margin: 0 0 20px; margin: 0 0 20px;
padding: 8px 12px; padding: 8px 12px;
font-size: 13px; font-size: 0.8125rem;
} }
/* Calendar and clock */ /* Calendar and clock */
@ -954,7 +965,7 @@ input[type="submit"], button {
.calendar-shortcuts { .calendar-shortcuts {
padding: 10px 0; padding: 10px 0;
font-size: 12px; font-size: 0.75rem;
line-height: 12px; line-height: 12px;
} }
@ -987,7 +998,7 @@ input[type="submit"], button {
/* History */ /* History */
table#change-history tbody th, table#change-history tbody td { table#change-history tbody th, table#change-history tbody td {
font-size: 13px; font-size: 0.8125rem;
word-break: break-word; word-break: break-word;
} }
@ -998,7 +1009,7 @@ input[type="submit"], button {
/* Docs */ /* Docs */
table.model tbody th, table.model tbody td { table.model tbody th, table.model tbody td {
font-size: 13px; font-size: 0.8125rem;
word-break: break-word; word-break: break-word;
} }
} }

View File

@ -175,12 +175,24 @@ fieldset .fieldBox {
top: 0; top: 0;
left: auto; left: auto;
right: 10px; right: 10px;
background: url(../img/calendar-icons.svg) 0 -30px no-repeat;
}
.calendarbox .calendarnav-previous:focus,
.calendarbox .calendarnav-previous:hover {
background-position: 0 -45px;
} }
.calendarnav-next { .calendarnav-next {
top: 0; top: 0;
right: auto; right: auto;
left: 10px; left: 10px;
background: url(../img/calendar-icons.svg) 0 0 no-repeat;
}
.calendarbox .calendarnav-next:focus,
.calendarbox .calendarnav-next:hover {
background-position: 0 -15px;
} }
.calendar caption, .calendarbox h2 { .calendar caption, .calendarbox h2 {

View File

@ -3,18 +3,21 @@
.selector { .selector {
width: 800px; width: 800px;
float: left; float: left;
display: flex;
} }
.selector select { .selector select {
width: 380px; width: 380px;
height: 17.2em; height: 17.2em;
flex: 1 0 auto;
} }
.selector-available, .selector-chosen { .selector-available, .selector-chosen {
float: left;
width: 380px; width: 380px;
text-align: center; text-align: center;
margin-bottom: 5px; margin-bottom: 5px;
display: flex;
flex-direction: column;
} }
.selector-chosen select { .selector-chosen select {
@ -41,7 +44,7 @@
border-width: 0 1px; border-width: 0 1px;
padding: 8px; padding: 8px;
color: var(--body-quiet-color); color: var(--body-quiet-color);
font-size: 10px; font-size: 0.625rem;
margin: 0; margin: 0;
text-align: left; text-align: left;
} }
@ -63,12 +66,13 @@
} }
.selector ul.selector-chooser { .selector ul.selector-chooser {
float: left; align-self: center;
width: 22px; width: 22px;
background-color: var(--selected-bg); background-color: var(--selected-bg);
border-radius: 10px; border-radius: 10px;
margin: 10em 5px 0 5px; margin: 0 5px;
padding: 0; padding: 0;
transform: translateY(-17px);
} }
.selector-chooser li { .selector-chooser li {
@ -168,6 +172,7 @@ a.active.selector-clearall:focus, a.active.selector-clearall:hover {
.stacked { .stacked {
float: left; float: left;
width: 490px; width: 490px;
display: block;
} }
.stacked select { .stacked select {
@ -193,6 +198,7 @@ a.active.selector-clearall:focus, a.active.selector-clearall:hover {
margin: 0 0 10px 40%; margin: 0 0 10px 40%;
background-color: #eee; background-color: #eee;
border-radius: 10px; border-radius: 10px;
transform: none;
} }
.stacked .selector-chooser li { .stacked .selector-chooser li {
@ -267,7 +273,7 @@ p.datetime {
.datetime span { .datetime span {
white-space: nowrap; white-space: nowrap;
font-weight: normal; font-weight: normal;
font-size: 11px; font-size: 0.6875rem;
color: var(--body-quiet-color); color: var(--body-quiet-color);
} }
@ -277,7 +283,7 @@ p.datetime {
} }
table p.datetime { table p.datetime {
font-size: 11px; font-size: 0.6875rem;
margin-left: 0; margin-left: 0;
padding-left: 0; padding-left: 0;
} }
@ -311,7 +317,7 @@ table p.datetime {
} }
.timezonewarning { .timezonewarning {
font-size: 11px; font-size: 0.6875rem;
color: var(--body-quiet-color); color: var(--body-quiet-color);
} }
@ -322,7 +328,7 @@ p.url {
margin: 0; margin: 0;
padding: 0; padding: 0;
color: var(--body-quiet-color); color: var(--body-quiet-color);
font-size: 11px; font-size: 0.6875rem;
font-weight: bold; font-weight: bold;
} }
@ -337,7 +343,7 @@ p.file-upload {
margin: 0; margin: 0;
padding: 0; padding: 0;
color: var(--body-quiet-color); color: var(--body-quiet-color);
font-size: 11px; font-size: 0.6875rem;
font-weight: bold; font-weight: bold;
} }
@ -355,7 +361,7 @@ p.file-upload {
span.clearable-file-input label { span.clearable-file-input label {
color: var(--body-fg); color: var(--body-fg);
font-size: 11px; font-size: 0.6875rem;
display: inline; display: inline;
float: none; float: none;
} }
@ -364,7 +370,7 @@ span.clearable-file-input label {
.calendarbox, .clockbox { .calendarbox, .clockbox {
margin: 5px auto; margin: 5px auto;
font-size: 12px; font-size: 0.75rem;
width: 19em; width: 19em;
text-align: center; text-align: center;
background: var(--body-bg); background: var(--body-bg);
@ -398,7 +404,7 @@ span.clearable-file-input label {
text-align: center; text-align: center;
border-top: none; border-top: none;
font-weight: 700; font-weight: 700;
font-size: 12px; font-size: 0.75rem;
color: #333; color: #333;
background: var(--accent); background: var(--accent);
} }
@ -408,14 +414,14 @@ span.clearable-file-input label {
background: var(--darkened-bg); background: var(--darkened-bg);
border-bottom: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color);
font-weight: 400; font-weight: 400;
font-size: 12px; font-size: 0.75rem;
text-align: center; text-align: center;
color: var(--body-quiet-color); color: var(--body-quiet-color);
} }
.calendar td { .calendar td {
font-weight: 400; font-weight: 400;
font-size: 12px; font-size: 0.75rem;
text-align: center; text-align: center;
padding: 0; padding: 0;
border-top: 1px solid var(--hairline-color); border-top: 1px solid var(--hairline-color);
@ -455,7 +461,7 @@ span.clearable-file-input label {
} }
.calendarnav { .calendarnav {
font-size: 10px; font-size: 0.625rem;
text-align: center; text-align: center;
color: #ccc; color: #ccc;
margin: 0; margin: 0;
@ -470,7 +476,7 @@ span.clearable-file-input label {
.calendar-shortcuts { .calendar-shortcuts {
background: var(--body-bg); background: var(--body-bg);
color: var(--body-quiet-color); color: var(--body-quiet-color);
font-size: 11px; font-size: 0.6875rem;
line-height: 11px; line-height: 11px;
border-top: 1px solid var(--hairline-color); border-top: 1px solid var(--hairline-color);
padding: 8px 0; padding: 8px 0;
@ -509,7 +515,7 @@ span.clearable-file-input label {
.calendar-cancel { .calendar-cancel {
margin: 0; margin: 0;
padding: 4px 0; padding: 4px 0;
font-size: 12px; font-size: 0.75rem;
background: #eee; background: #eee;
border-top: 1px solid var(--border-color); border-top: 1px solid var(--border-color);
color: var(--body-fg); color: var(--body-fg);

View File

@ -153,24 +153,6 @@ Requires core.js and SelectBox.js.
// Move selected from_box options to to_box // Move selected from_box options to to_box
SelectBox.move(field_id + '_from', field_id + '_to'); SelectBox.move(field_id + '_from', field_id + '_to');
if (!is_stacked) {
// In horizontal mode, give the same height to the two boxes.
const j_from_box = document.getElementById(field_id + '_from');
const j_to_box = document.getElementById(field_id + '_to');
let height = filter_p.offsetHeight + j_from_box.offsetHeight;
const j_to_box_style = window.getComputedStyle(j_to_box);
if (j_to_box_style.getPropertyValue('box-sizing') === 'border-box') {
// Add the padding and border to the final height.
height += parseInt(j_to_box_style.getPropertyValue('padding-top'), 10)
+ parseInt(j_to_box_style.getPropertyValue('padding-bottom'), 10)
+ parseInt(j_to_box_style.getPropertyValue('border-top-width'), 10)
+ parseInt(j_to_box_style.getPropertyValue('border-bottom-width'), 10);
}
j_to_box.style.height = height + 'px';
}
// Initial icon refresh // Initial icon refresh
SelectFilter.refresh_icons(field_id); SelectFilter.refresh_icons(field_id);
}, },

View File

@ -388,13 +388,7 @@
DateTimeShortcuts.calendars[num].drawNextMonth(); DateTimeShortcuts.calendars[num].drawNextMonth();
}, },
handleCalendarCallback: function(num) { handleCalendarCallback: function(num) {
let format = get_format('DATE_INPUT_FORMATS')[0]; const format = get_format('DATE_INPUT_FORMATS')[0];
// the format needs to be escaped a little
format = format.replace('\\', '\\\\')
.replace('\r', '\\r')
.replace('\n', '\\n')
.replace('\t', '\\t')
.replace("'", "\\'");
return function(y, m, d) { return function(y, m, d) {
DateTimeShortcuts.calendarInputs[num].value = new Date(y, m - 1, d).strftime(format); DateTimeShortcuts.calendarInputs[num].value = new Date(y, m - 1, d).strftime(format);
DateTimeShortcuts.calendarInputs[num].focus(); DateTimeShortcuts.calendarInputs[num].focus();

View File

@ -4,14 +4,45 @@
'use strict'; 'use strict';
{ {
const $ = django.jQuery; const $ = django.jQuery;
let popupIndex = 0;
const relatedWindows = [];
function dismissChildPopups() {
relatedWindows.forEach(function(win) {
if(!win.closed) {
win.dismissChildPopups();
win.close();
}
});
}
function setPopupIndex() {
if(document.getElementsByName("_popup").length > 0) {
const index = window.name.lastIndexOf("__") + 2;
popupIndex = parseInt(window.name.substring(index));
} else {
popupIndex = 0;
}
}
function addPopupIndex(name) {
name = name + "__" + (popupIndex + 1);
return name;
}
function removePopupIndex(name) {
name = name.replace(new RegExp("__" + (popupIndex + 1) + "$"), '');
return name;
}
function showAdminPopup(triggeringLink, name_regexp, add_popup) { function showAdminPopup(triggeringLink, name_regexp, add_popup) {
const name = triggeringLink.id.replace(name_regexp, ''); const name = addPopupIndex(triggeringLink.id.replace(name_regexp, ''));
const href = new URL(triggeringLink.href); const href = new URL(triggeringLink.href);
if (add_popup) { if (add_popup) {
href.searchParams.set('_popup', 1); href.searchParams.set('_popup', 1);
} }
const win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes'); const win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
relatedWindows.push(win);
win.focus(); win.focus();
return false; return false;
} }
@ -21,13 +52,17 @@
} }
function dismissRelatedLookupPopup(win, chosenId) { function dismissRelatedLookupPopup(win, chosenId) {
const name = win.name; const name = removePopupIndex(win.name);
const elem = document.getElementById(name); const elem = document.getElementById(name);
if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) { if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) {
elem.value += ',' + chosenId; elem.value += ',' + chosenId;
} else { } else {
document.getElementById(name).value = chosenId; document.getElementById(name).value = chosenId;
} }
const index = relatedWindows.indexOf(win);
if (index > -1) {
relatedWindows.splice(index, 1);
}
win.close(); win.close();
} }
@ -52,13 +87,44 @@
} }
} }
function updateRelatedSelectsOptions(currentSelect, win, objId, newRepr, newId) {
// After create/edit a model from the options next to the current
// select (+ or :pencil:) update ForeignKey PK of the rest of selects
// in the page.
const path = win.location.pathname;
// Extract the model from the popup url '.../<model>/add/' or
// '.../<model>/<id>/change/' depending the action (add or change).
const modelName = path.split('/')[path.split('/').length - (objId ? 4 : 3)];
// Exclude autocomplete selects.
const selectsRelated = document.querySelectorAll(`[data-model-ref="${modelName}"] select:not(.admin-autocomplete)`);
selectsRelated.forEach(function(select) {
if (currentSelect === select) {
return;
}
let option = select.querySelector(`option[value="${objId}"]`);
if (!option) {
option = new Option(newRepr, newId);
select.options.add(option);
return;
}
option.textContent = newRepr;
option.value = newId;
});
}
function dismissAddRelatedObjectPopup(win, newId, newRepr) { function dismissAddRelatedObjectPopup(win, newId, newRepr) {
const name = win.name; const name = removePopupIndex(win.name);
const elem = document.getElementById(name); const elem = document.getElementById(name);
if (elem) { if (elem) {
const elemName = elem.nodeName.toUpperCase(); const elemName = elem.nodeName.toUpperCase();
if (elemName === 'SELECT') { if (elemName === 'SELECT') {
elem.options[elem.options.length] = new Option(newRepr, newId, true, true); elem.options[elem.options.length] = new Option(newRepr, newId, true, true);
updateRelatedSelectsOptions(elem, win, null, newRepr, newId);
} else if (elemName === 'INPUT') { } else if (elemName === 'INPUT') {
if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) { if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) {
elem.value += ',' + newId; elem.value += ',' + newId;
@ -74,11 +140,15 @@
SelectBox.add_to_cache(toId, o); SelectBox.add_to_cache(toId, o);
SelectBox.redisplay(toId); SelectBox.redisplay(toId);
} }
const index = relatedWindows.indexOf(win);
if (index > -1) {
relatedWindows.splice(index, 1);
}
win.close(); win.close();
} }
function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) { function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) {
const id = win.name.replace(/^edit_/, ''); const id = removePopupIndex(win.name.replace(/^edit_/, ''));
const selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]); const selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
const selects = $(selectsSelector); const selects = $(selectsSelector);
selects.find('option').each(function() { selects.find('option').each(function() {
@ -86,18 +156,23 @@
this.textContent = newRepr; this.textContent = newRepr;
this.value = newId; this.value = newId;
} }
}); }).trigger('change');
updateRelatedSelectsOptions(selects[0], win, objId, newRepr, newId);
selects.next().find('.select2-selection__rendered').each(function() { selects.next().find('.select2-selection__rendered').each(function() {
// The element can have a clear button as a child. // The element can have a clear button as a child.
// Use the lastChild to modify only the displayed value. // Use the lastChild to modify only the displayed value.
this.lastChild.textContent = newRepr; this.lastChild.textContent = newRepr;
this.title = newRepr; this.title = newRepr;
}); });
const index = relatedWindows.indexOf(win);
if (index > -1) {
relatedWindows.splice(index, 1);
}
win.close(); win.close();
} }
function dismissDeleteRelatedObjectPopup(win, objId) { function dismissDeleteRelatedObjectPopup(win, objId) {
const id = win.name.replace(/^delete_/, ''); const id = removePopupIndex(win.name.replace(/^delete_/, ''));
const selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]); const selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
const selects = $(selectsSelector); const selects = $(selectsSelector);
selects.find('option').each(function() { selects.find('option').each(function() {
@ -105,6 +180,10 @@
$(this).remove(); $(this).remove();
} }
}).trigger('change'); }).trigger('change');
const index = relatedWindows.indexOf(win);
if (index > -1) {
relatedWindows.splice(index, 1);
}
win.close(); win.close();
} }
@ -115,17 +194,23 @@
window.dismissAddRelatedObjectPopup = dismissAddRelatedObjectPopup; window.dismissAddRelatedObjectPopup = dismissAddRelatedObjectPopup;
window.dismissChangeRelatedObjectPopup = dismissChangeRelatedObjectPopup; window.dismissChangeRelatedObjectPopup = dismissChangeRelatedObjectPopup;
window.dismissDeleteRelatedObjectPopup = dismissDeleteRelatedObjectPopup; window.dismissDeleteRelatedObjectPopup = dismissDeleteRelatedObjectPopup;
window.dismissChildPopups = dismissChildPopups;
// Kept for backward compatibility // Kept for backward compatibility
window.showAddAnotherPopup = showRelatedObjectPopup; window.showAddAnotherPopup = showRelatedObjectPopup;
window.dismissAddAnotherPopup = dismissAddRelatedObjectPopup; window.dismissAddAnotherPopup = dismissAddRelatedObjectPopup;
window.addEventListener('unload', function(evt) {
window.dismissChildPopups();
});
$(document).ready(function() { $(document).ready(function() {
setPopupIndex();
$("a[data-popup-opener]").on('click', function(event) { $("a[data-popup-opener]").on('click', function(event) {
event.preventDefault(); event.preventDefault();
opener.dismissRelatedLookupPopup(window, $(this).data("popup-opener")); opener.dismissRelatedLookupPopup(window, $(this).data("popup-opener"));
}); });
$('body').on('click', '.related-widget-wrapper-link', function(e) { $('body').on('click', '.related-widget-wrapper-link[data-popup="yes"]', function(e) {
e.preventDefault(); e.preventDefault();
if (this.href) { if (this.href) {
const event = $.Event('django:show-related', {href: this.href}); const event = $.Event('django:show-related', {href: this.href});

View File

@ -27,9 +27,7 @@
$('.admin-autocomplete').not('[name*=__prefix__]').djangoAdminSelect2(); $('.admin-autocomplete').not('[name*=__prefix__]').djangoAdminSelect2();
}); });
$(document).on('formset:added', (function() { document.addEventListener('formset:added', (event) => {
return function(event, $newFormset) { $(event.target).find('.admin-autocomplete').djangoAdminSelect2();
return $newFormset.find('.admin-autocomplete').djangoAdminSelect2(); });
};
})(this));
} }

View File

@ -0,0 +1,30 @@
/**
* Persist changelist filters state (collapsed/expanded).
*/
'use strict';
{
// Init filters.
let filters = JSON.parse(sessionStorage.getItem('django.admin.filtersState'));
if (!filters) {
filters = {};
}
Object.entries(filters).forEach(([key, value]) => {
const detailElement = document.querySelector(`[data-filter-title='${key}']`);
// Check if the filter is present, it could be from other view.
if (detailElement) {
value ? detailElement.setAttribute('open', '') : detailElement.removeAttribute('open');
}
});
// Save filter state when clicks.
const details = document.querySelectorAll('details');
details.forEach(detail => {
detail.addEventListener('toggle', event => {
filters[`${event.target.dataset.filterTitle}`] = detail.open;
sessionStorage.setItem('django.admin.filtersState', JSON.stringify(filters));
});
});
}

View File

@ -88,7 +88,12 @@
if (options.added) { if (options.added) {
options.added(row); options.added(row);
} }
$(document).trigger('formset:added', [row, options.prefix]); row.get(0).dispatchEvent(new CustomEvent("formset:added", {
bubbles: true,
detail: {
formsetName: options.prefix
}
}));
}; };
/** /**
@ -130,7 +135,11 @@
if (options.removed) { if (options.removed) {
options.removed(row); options.removed(row);
} }
$(document).trigger('formset:removed', [row, options.prefix]); document.dispatchEvent(new CustomEvent("formset:removed", {
detail: {
formsetName: options.prefix
}
}));
// Update the TOTAL_FORMS form count. // Update the TOTAL_FORMS form count.
const forms = $("." + options.formCssClass); const forms = $("." + options.formCssClass);
$("#id_" + options.prefix + "-TOTAL_FORMS").val(forms.length); $("#id_" + options.prefix + "-TOTAL_FORMS").val(forms.length);
@ -296,7 +305,13 @@
dependency_list = input.data('dependency_list') || [], dependency_list = input.data('dependency_list') || [],
dependencies = []; dependencies = [];
$.each(dependency_list, function(i, field_name) { $.each(dependency_list, function(i, field_name) {
dependencies.push('#' + row.find('.form-row .field-' + field_name).find('input, select, textarea').attr('id')); // Dependency in a fieldset.
let field_element = row.find('.form-row .field-' + field_name);
// Dependency without a fieldset.
if (!field_element.length) {
field_element = row.find('.form-row.field-' + field_name);
}
dependencies.push('#' + field_element.find('input, select, textarea').attr('id'));
}); });
if (dependencies.length) { if (dependencies.length) {
input.prepopulate(dependencies, input.attr('maxlength')); input.prepopulate(dependencies, input.attr('maxlength'));

View File

@ -3,7 +3,11 @@
const $ = django.jQuery; const $ = django.jQuery;
const fields = $('#django-admin-prepopulated-fields-constants').data('prepopulatedFields'); const fields = $('#django-admin-prepopulated-fields-constants').data('prepopulatedFields');
$.each(fields, function(index, field) { $.each(fields, function(index, field) {
$('.empty-form .form-row .field-' + field.name + ', .empty-form.form-row .field-' + field.name).addClass('prepopulated_field'); $(
'.empty-form .form-row .field-' + field.name +
', .empty-form.form-row .field-' + field.name +
', .empty-form .form-row.field-' + field.name
).addClass('prepopulated_field');
$(field.id).data('dependency_list', field.dependency_list).prepopulate( $(field.id).data('dependency_list', field.dependency_list).prepopulate(
field.dependency_ids, field.maxLength, field.allowUnicode field.dependency_ids, field.maxLength, field.allowUnicode
); );

View File

@ -1295,6 +1295,10 @@ select {
margin: 1rem; margin: 1rem;
} }
.m-0 {
margin: 0px;
}
.mx-auto { .mx-auto {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@ -1310,6 +1314,21 @@ select {
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
.my-5 {
margin-top: 1.25rem;
margin-bottom: 1.25rem;
}
.my-3 {
margin-top: 0.75rem;
margin-bottom: 0.75rem;
}
.my-6 {
margin-top: 1.5rem;
margin-bottom: 1.5rem;
}
.mb-2 { .mb-2 {
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
@ -1334,6 +1353,10 @@ select {
margin-bottom: auto; margin-bottom: auto;
} }
.ml-2 {
margin-left: 0.5rem;
}
.block { .block {
display: block; display: block;
} }
@ -1342,10 +1365,6 @@ select {
display: inline-block; display: inline-block;
} }
.inline {
display: inline;
}
.flex { .flex {
display: flex; display: flex;
} }
@ -1354,10 +1373,6 @@ select {
display: table; display: table;
} }
.grid {
display: grid;
}
.contents { .contents {
display: contents; display: contents;
} }
@ -1366,6 +1381,10 @@ select {
display: none; display: none;
} }
.h-auto {
height: auto;
}
.h-screen { .h-screen {
height: 100vh; height: 100vh;
} }
@ -1418,10 +1437,6 @@ select {
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
} }
.resize {
resize: both;
}
.flex-row { .flex-row {
flex-direction: row; flex-direction: row;
} }
@ -1667,15 +1682,6 @@ select {
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
} }
.outline {
outline-style: solid;
}
.blur {
--tw-blur: blur(8px);
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}
.filter { .filter {
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow); filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
} }

View File

@ -1081,22 +1081,6 @@ select {
margin-bottom: 0; margin-bottom: 0;
} }
.btn {
display: inline-block;
border-radius: 0.375rem;
border-width: 1px;
-webkit-text-decoration-line: none;
text-decoration-line: none;
--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
transition-property: color, background-color, border-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-text-decoration-color, -webkit-backdrop-filter;
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-text-decoration-color, -webkit-backdrop-filter;
transition-duration: 300ms;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
.button { .button {
display: inline-block; display: inline-block;
border-radius: 0.375rem; border-radius: 0.375rem;
@ -1381,10 +1365,6 @@ select {
display: inline-block; display: inline-block;
} }
.inline {
display: inline;
}
.flex { .flex {
display: flex; display: flex;
} }
@ -1393,10 +1373,6 @@ select {
display: table; display: table;
} }
.grid {
display: grid;
}
.contents { .contents {
display: contents; display: contents;
} }
@ -1461,10 +1437,6 @@ select {
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
} }
.resize {
resize: both;
}
.flex-row { .flex-row {
flex-direction: row; flex-direction: row;
} }
@ -1710,15 +1682,6 @@ select {
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
} }
.outline {
outline-style: solid;
}
.blur {
--tw-blur: blur(8px);
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}
.filter { .filter {
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow); filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
} }