Browse Source

Merge remote-tracking branch 'origin/prednasky'

Conflicts:
	seminar/models.py
remotes/origin/bug
Bc. Petr Pecha 9 years ago
parent
commit
097c34ec87
  1. 1
      mamweb/settings_common.py
  2. 0
      prednasky/__init__.py
  3. 7
      prednasky/admin.py
  4. 8
      prednasky/forms.py
  5. 45
      prednasky/migrations/0001_initial.py
  6. 24
      prednasky/migrations/0002_auto_20160417_2347.py
  7. 0
      prednasky/migrations/__init__.py
  8. 34
      prednasky/models.py
  9. 40
      prednasky/templates/prednasky/Base.html
  10. 11
      prednasky/templates/prednasky/hotovo.html
  11. 3
      prednasky/tests.py
  12. 38
      prednasky/views.py
  13. 5
      seminar/models.py
  14. 5
      seminar/urls.py

1
mamweb/settings_common.py

@ -121,6 +121,7 @@ INSTALLED_APPS = (
'seminar',
'galerie',
'korektury',
'prednasky',
# Admin upravy:

0
prednasky/__init__.py

7
prednasky/admin.py

@ -0,0 +1,7 @@
from django.contrib import admin
from models import Prednaska, Seznam, Hlasovani
admin.site.register(Seznam)
admin.site.register(Prednaska)
admin.site.register(Hlasovani)

8
prednasky/forms.py

@ -0,0 +1,8 @@
# coding: utf-8
from django import forms
class NewPrednaskyForm(forms.Form):
ucastnik = forms.CharField(label = 'Tvoje jméno', max_length = 100)

45
prednasky/migrations/0001_initial.py

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('seminar', '0036_add_org_to_soustredeni'),
]
operations = [
migrations.CreateModel(
name='Hlasovani',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('body', models.IntegerField(default=0, verbose_name=b'Body', choices=[(0, b'0'), (1, b'1'), (-1, b'-1')])),
('ucastnik', models.CharField(max_length=100, verbose_name=b'\xc3\x9a\xc4\x8dastn\xc3\xadk')),
],
),
migrations.CreateModel(
name='Prednaska',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('nazev', models.CharField(max_length=300, verbose_name=b'N\xc3\xa1zev')),
('anotace', models.TextField(verbose_name=b'Anotace')),
('obtiznost', models.IntegerField(verbose_name=b'Obt\xc3\xad\xc5\xbenost', choices=[(1, b'Lehk\xc3\xa1'), (2, b'St\xc5\x99edn\xc3\xad'), (3, b'T\xc4\x9b\xc5\xbek\xc3\xa1')])),
('obor', models.CharField(max_length=5, verbose_name=b'Obor')),
('klicova', models.CharField(max_length=200, null=True, verbose_name=b'Kl\xc3\xad\xc4\x8dov\xc3\xa1 slova', blank=True)),
('org', models.ForeignKey(to='seminar.Organizator')),
],
),
migrations.CreateModel(
name='Seznam',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
],
),
migrations.AddField(
model_name='hlasovani',
name='prednaska',
field=models.ForeignKey(to='prednasky.Prednaska'),
),
]

24
prednasky/migrations/0002_auto_20160417_2347.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('prednasky', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='prednaska',
name='seznam',
field=models.ForeignKey(default=None, blank=True, to='prednasky.Seznam'),
),
migrations.AlterField(
model_name='hlasovani',
name='body',
field=models.IntegerField(default=0, verbose_name=b'Body', choices=[(-1, b'-1'), (0, b'0'), (1, b'1')]),
),
]

0
prednasky/migrations/__init__.py

34
prednasky/models.py

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
from django.db import models
from seminar.models import Organizator
class Seznam(models.Model):
pass
CHOICES_OBTIZNOST = (
(1, 'Lehká'),
(2, 'Střední'),
(3, 'Těžká'),
)
CHOICES_BODY = (
(-1, '-1'),
(0, '0'),
(1, '1'),
)
class Prednaska(models.Model):
nazev = models.CharField('Název', max_length = 300)
org = models.ForeignKey(Organizator)
anotace = models.TextField('Anotace')
obtiznost = models.IntegerField('Obtížnost', choices=CHOICES_OBTIZNOST)
obor = models.CharField('Obor', max_length = 5)
klicova = models.CharField('Klíčová slova', max_length = 200, null = True, blank = True)
seznam = models.ForeignKey(Seznam, blank = True, default = None)
class Hlasovani(models.Model):
prednaska = models.ForeignKey(Prednaska)
body = models.IntegerField('Body', default = 0, choices = CHOICES_BODY)
ucastnik = models.CharField('Účastník', max_length = 100)

40
prednasky/templates/prednasky/Base.html

@ -0,0 +1,40 @@
{% extends 'base.html' %}
{% load humanize %}
{% load staticfiles %}
{% block title %}
Hlasování o přednáškách
{% endblock %}
{% block content %}
<p>
Jak moc by ses chtěl(a) zúčastnit následujících přednášek?
<br>
<span style="font-size: 75%">Obtížnost 1 je nejlehčí, 3 nejtěžší.</span>
</p>
<form enctype="multipart/form-data" action="." method="post">
{% csrf_token %}
<table>{{form.as_table}}
</table>
<table>
{% for p in prednasky.prednaska_set.all %}
<tr><td><label>{{p.org}}: <span style="font-size: 175%">{{p.nazev}}</span></label></td></tr>
<tr><td><p><i>{{p.anotace}}</i></p></td></tr>
<tr><td><label>Obor: </label> {{p.obor}}</td></tr>
<tr><td><label>Obtížnost: </label> {{p.obtiznost}}</td> </tr>
{% if p.klicova %}<tr><td><label>Klíčová slova: </label> {{p.klicova}}</td></tr>{% endif%}
<tr><td>Hodnocení:
<INPUT TYPE="radio" NAME="q{{p.pk}}" VALUE="-1"> rozhodně nechci
<INPUT TYPE="radio" NAME="q{{p.pk}}" VALUE="0" checked> je mi to jedno
<INPUT TYPE="radio" NAME="q{{p.pk}}" VALUE="1"> rozhodně chci
</td></tr>
<tr><td>&nbsp;</td></tr>
{% endfor %}
<tr><td><input name="odeslat" type="submit" value="Odeslat"></td><tr>
</table>
</form>
{% endblock %}

11
prednasky/templates/prednasky/hotovo.html

@ -0,0 +1,11 @@
{% extends 'base.html' %}
{% load humanize %}
{% load staticfiles %}
{% block content %}
<h1> Děkujeme. </h1>
{% endblock %}

3
prednasky/tests.py

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

38
prednasky/views.py

@ -0,0 +1,38 @@
from django.shortcuts import render
from prednasky.forms import NewPrednaskyForm
from prednasky.models import Seznam, Hlasovani, Prednaska
from django.shortcuts import HttpResponseRedirect
def newPrednaska(request):
# zjistime k jakemu soustredeni se vaze nove vytvarena galerie
prednasky = Seznam.objects.first()
# obsluha formulare umoznujiciho multiple nahravani fotek
if request.method == 'POST':
form = NewPrednaskyForm(request.POST, request.FILES)
if form.is_valid():
jmeno = form.cleaned_data['ucastnik']
for i in request.POST:
if i[0] == 'q':
hlasovani = Hlasovani()
print("q:"+i[1:])
hlasovani.prednaska = Prednaska.objects.filter(pk = int(i[1:]))[0]
hlasovani.body = int(request.POST[i])
hlasovani.ucastnik = jmeno
hlasovani.save()
# presmerovani na prave vzniklou galerii
return HttpResponseRedirect('./hotovo')
else:
form = NewPrednaskyForm()
return render(request, 'prednasky/Base.html',
{ 'form' : form,
'prednasky' : prednasky,
})
def Prednaska_hotovo(request):
return render(request, 'prednasky/hotovo.html')
# Create your views here.

5
seminar/models.py

@ -550,6 +550,7 @@ class Reseni(SeminarModelBase):
# TODO vyresit partial, tak aby slo migrovat
#def generate_filename(self, filename, directory):
# Django 1.9 podporuje partial
def generate_filename(self, filename):
clean = filename.replace('/','-').replace('\0', '')
datedir = timezone.now().strftime('%Y-%m')
@ -557,6 +558,7 @@ def generate_filename(self, filename):
timezone.now().strftime('%Y-%m-%d-%H:%M'),
clean)
return os.path.join(settings.SEMINAR_RESENI_DIR, datedir, fname)
def generate_filename_konfera(self, filename):
clean = filename.replace('/','-').replace('\0', '')
datedir = timezone.now().strftime('%Y-%m')
@ -568,7 +570,6 @@ def generate_filename_konfera(self, filename):
# return os.path.join(directory, datedir, fname)
@reversion.register(ignore_duplicate_revisions=True)
@python_2_unicode_compatible
class PrilohaReseni(SeminarModelBase):
@ -586,8 +587,6 @@ class PrilohaReseni(SeminarModelBase):
timestamp = models.DateTimeField(u'vytvořeno', default=timezone.now, blank=True, editable=False)
#soubor = models.FileField(u'soubor', upload_to = partial(generate_filename,directory=settings.SEMINAR_RESENI_DIR)))
# TODO vyresit partial tak, aby slo migrovat
soubor = models.FileField(u'soubor', upload_to = generate_filename)
poznamka = models.TextField(u'neveřejná poznámka', blank=True,

5
seminar/urls.py

@ -3,10 +3,15 @@ from django.conf.urls import patterns, url
from django.contrib.auth.decorators import user_passes_test
from . import views, export
from utils import staff_member_required
from prednasky.views import newPrednaska, Prednaska_hotovo
staff_member_required = user_passes_test(lambda u: u.is_staff)
urlpatterns = [
# prednasky
url(r'^prednasky/$', newPrednaska),
url(r'^prednasky/hotovo$', Prednaska_hotovo),
url(r'^co-je-MaM/organizatori/$', views.CojemamOrganizatoriView.as_view(), name='organizatori'),
url(r'^co-je-MaM/organizatori/organizovali/$', views.CojemamOrganizatoriStariView.as_view(), name='stari_organizatori'),

Loading…
Cancel
Save