Browse Source

Organizatori | ListView + template

Nutno pak dostylovat podle vzhledu.
Zaklad zobrazovanych informaci.
Nutno rozdelit na aktivni a neaktivni
a to idealne tak, ze template bude jeden
a list se zpravne zkompetuje ve view.
remotes/origin/vysl
Bc. Petr Pecha 10 years ago
parent
commit
3a8f2ec35e
  1. 20
      seminar/migrations/0025_zmena_cesty_nahravani_obrazku.py
  2. 2
      seminar/models.py
  3. 29
      seminar/templates/seminar/cojemam/organizatori.html
  4. 5
      seminar/views.py

20
seminar/migrations/0025_zmena_cesty_nahravani_obrazku.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('seminar', '0024_add_organizator'),
]
operations = [
migrations.AlterField(
model_name='organizator',
name='foto',
field=models.ImageField(help_text=b'Vlo\xc5\xbe fotografii organiz\xc3\xa1tora o libovon\xc3\xa9 velikosti', upload_to=b'image_organizatori/velke/%Y/', null=True, verbose_name=b'Fotografie organiz\xc3\xa1tora', blank=True),
preserve_default=True,
),
]

2
seminar/models.py

@ -681,7 +681,7 @@ class Organizator(models.Model):
strucny_popis_organizatora = models.TextField('Stručný popis organizátora', strucny_popis_organizatora = models.TextField('Stručný popis organizátora',
null = True, blank = True) null = True, blank = True)
foto = models.ImageField('Fotografie organizátora', foto = models.ImageField('Fotografie organizátora',
upload_to='image_organizatori/%Y/', null = True, blank = True, upload_to='image_organizatori/velke/%Y/', null = True, blank = True,
help_text = 'Vlož fotografii organizátora o libovoné velikosti') help_text = 'Vlož fotografii organizátora o libovoné velikosti')
foto_male = models.ImageField(upload_to='image_organizatori/male/%Y/', foto_male = models.ImageField(upload_to='image_organizatori/male/%Y/',
null = True, blank = True, editable = False) null = True, blank = True, editable = False)

29
seminar/templates/seminar/cojemam/organizatori.html

@ -4,6 +4,35 @@
<div> <div>
<h2>Organizátoři</h2> <h2>Organizátoři</h2>
{% for org in object_list %}
{{org.user.first_name}}
{% if org.prezdivka %}
"{{org.prezdivka}}"
{% endif %}
{{org.user.last_name}} <br>
<ul>
{% if org.organizuje_od_roku %}
<li>Organizuje od roku: {{org.organizuje_od_roku}}
{% endif %}
{% if org.organizuje_do_roku %}
<li>Organizuje do roku: {{org.organizuje_do_roku}}
{% endif %}
{% if org.studuje %}
<li>Studuje: {{org.studuje}}
{% endif %}
{% if org.user.email %}
<li>Pošta: {{org.user.email}}
{% endif %}
</ul>
{% if org.foto %}
<div class="foto_org">
<img src="{{org.foto.url}}" height="{{org.foto.height}}">
<img src="{{org.foto_male.url}}" height="{{org.foto_male.height}}"
</div>
{% endif %}
<hr>
{% endfor %}
</div> </div>
{% endblock content %} {% endblock content %}

5
seminar/views.py

@ -5,7 +5,7 @@ from django.views import generic
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.http import Http404 from django.http import Http404
from .models import Problem, Cislo, Reseni, VysledkyKCislu, Nastaveni, Rocnik, Soustredeni from .models import Problem, Cislo, Reseni, VysledkyKCislu, Nastaveni, Rocnik, Soustredeni, Organizator
def AktualniZadaniView(request): def AktualniZadaniView(request):
@ -17,7 +17,8 @@ def AktualniZadaniView(request):
# Co je M&M # Co je M&M
class CojemamOrganizatoriView(generic.TemplateView): class CojemamOrganizatoriView(generic.ListView):
model = Organizator
template_name='seminar/cojemam/organizatori.html' template_name='seminar/cojemam/organizatori.html'
class CislaView(generic.ListView): class CislaView(generic.ListView):

Loading…
Cancel
Save