Merge branch 'Petr'

This commit is contained in:
Bc. Petr Pecha 2015-06-23 11:47:32 +02:00
commit 29a65b064f
3 changed files with 66 additions and 1 deletions

View file

@ -8,7 +8,7 @@ from ckeditor.widgets import CKEditorWidget
from django.db.models import Count from django.db.models import Count
from django.db import models 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 import autocomplete_light
@ -317,3 +317,17 @@ class SoustredeniAdmin(reversion.VersionAdmin):
admin.site.register(Soustredeni, SoustredeniAdmin) 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)

View file

@ -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,),
),
]

View file

@ -618,3 +618,22 @@ class Nastaveni(SingletonModel):
def verejne(self): def verejne(self):
return False 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'