Browse Source

Merge branch 'Petr'

remotes/origin/vysl
Bc. Petr Pecha 10 years ago
parent
commit
29a65b064f
  1. 16
      seminar/admin.py
  2. 32
      seminar/migrations/0023_add_novinky.py
  3. 19
      seminar/models.py

16
seminar/admin.py

@ -8,7 +8,7 @@ from ckeditor.widgets import CKEditorWidget
from django.db.models import Count
from django.db import models
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Novinky
import autocomplete_light
@ -317,3 +317,17 @@ class SoustredeniAdmin(reversion.VersionAdmin):
admin.site.register(Soustredeni, SoustredeniAdmin)
### Novinky
class NovinkyAdminForm(forms.ModelForm):
text = forms.CharField(widget=CKEditorWidget(), required=False,
**field_labels(Novinky, 'text'))
class Meta:
model = Novinky
exclude = []
class NovinkyAdmin(admin.ModelAdmin):
form = NovinkyAdminForm
admin.site.register(Novinky, NovinkyAdmin)

32
seminar/migrations/0023_add_novinky.py

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('seminar', '0022_decimal_body'),
]
operations = [
migrations.CreateModel(
name='Novinky',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('datum', models.DateField(auto_now_add=True)),
('text', models.TextField(null=True, verbose_name=b'Text novinky', blank=True)),
('obrazek', models.ImageField(upload_to=b'image_novinky/%Y/%m/%d/', null=True, verbose_name=b'Obr\xc3\xa1zek', blank=True)),
('zverejneno', models.BooleanField(default=b'False', verbose_name=b'Zve\xc5\x99ejn\xc4\x9bno')),
('autor', models.ForeignKey(verbose_name=b'Autor novinky', to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'Novinka',
'verbose_name_plural': 'Novinky',
},
bases=(models.Model,),
),
]

19
seminar/models.py

@ -618,3 +618,22 @@ class Nastaveni(SingletonModel):
def verejne(self):
return False
@python_2_unicode_compatible
class Novinky(models.Model):
datum = models.DateField(auto_now_add=True)
text = models.TextField('Text novinky', blank=True, null=True)
obrazek = models.ImageField('Obrázek', upload_to='image_novinky/%Y/%m/%d/',
null=True, blank=True)
autor = models.ForeignKey(settings.AUTH_USER_MODEL,
verbose_name='Autor novinky')
zverejneno = models.BooleanField('Zveřejněno', default="False")
def __str__(self):
return '[' + str(self.datum) + '] ' + self.text[0:50]
class Meta:
verbose_name = 'Novinka'
verbose_name_plural = 'Novinky'

Loading…
Cancel
Save