Web M&M
https://mam.matfyz.cz
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.7 KiB
123 lines
3.7 KiB
# -*- coding: utf-8 -*-
|
|
import os
|
|
import random
|
|
from django.db import models
|
|
from django.contrib import auth
|
|
from django.utils import timezone
|
|
from django.conf import settings
|
|
from django.utils.encoding import python_2_unicode_compatible
|
|
from django.utils.encoding import force_unicode
|
|
from django.utils.text import slugify
|
|
from django.core.urlresolvers import reverse
|
|
from django.core.cache import cache
|
|
from imagekit.models import ImageSpecField, ProcessedImageField
|
|
from imagekit.processors import ResizeToFit, Transpose
|
|
|
|
from PIL import Image
|
|
import os
|
|
from cStringIO import StringIO
|
|
from django.core.files.base import ContentFile
|
|
|
|
from django_countries.fields import CountryField
|
|
from solo.models import SingletonModel
|
|
from taggit.managers import TaggableManager
|
|
|
|
import reversion
|
|
|
|
# PrilohaReseni method
|
|
def generate_filename(self, filename):
|
|
clean = filename.replace('/','-').replace('\0', '')
|
|
datedir = timezone.now().strftime('%Y-%m')
|
|
fname = "%s_%s" % (
|
|
timezone.now().strftime('%Y-%m-%d-%H:%M'),
|
|
clean)
|
|
return os.path.join(settings.SEMINAR_RESENI_DIR, datedir, fname)
|
|
|
|
|
|
#@reversion.register(ignore_duplicate_revision=True)
|
|
#@python_2_unicode_compatible
|
|
class KorekturovanePDF(models.Model):
|
|
class Meta:
|
|
db_table = 'korekturovane_cislo'
|
|
verbose_name = u'PDF k opravám'
|
|
verbose_name_plural = u'PDF k opravám'
|
|
|
|
#Interní ID
|
|
id = models.AutoField(primary_key = True)
|
|
|
|
pdf = models.FileField(u'pdf', upload_to = generate_filename)
|
|
|
|
#TODO Nepovinný foreign key k číslu
|
|
|
|
|
|
|
|
@reversion.register(ignore_duplicate_revision=True)
|
|
@python_2_unicode_compatible
|
|
class Oprava(models.Model):
|
|
class Meta:
|
|
db_table = 'opravy'
|
|
verbose_name = u'Oprava'
|
|
verbose_name_plural = u'Opravy'
|
|
ordering = ['y','x']
|
|
|
|
#Interní ID
|
|
id = models.AutoField(primary_key = True)
|
|
|
|
#pdf = models.ForeignKey(KorekturovanePDF)
|
|
|
|
strana = models.IntegerField(u'strana s opravou', help_text='Strana s opravou (od 0)')
|
|
|
|
x = models.IntegerField(u'x-ová souřadnice bugu')
|
|
y = models.IntegerField(u'y-ová souřadnice bugu')
|
|
|
|
STATUS_K_OPRAVE = 'k_oprave'
|
|
STATUS_OPRAVENO = 'opraveno'
|
|
STATUS_SMAZANO = 'smazano'
|
|
STATUS_CHOICES = (
|
|
(STATUS_K_OPRAVE, u'K opravě'),
|
|
(STATUS_OPRAVENO, u'Opraveno'),
|
|
(STATUS_SMAZANO, u'Smazáno'),
|
|
)
|
|
status = models.CharField(u'stav opravy',max_length=16, choices=STATUS_CHOICES, blank=False,
|
|
default = STATUS_K_OPRAVE)
|
|
|
|
|
|
# TODO: Změnit na cizí klíč do orgů
|
|
autor = models.TextField(u'autor opravy',blank = True, help_text='Autor opravy')
|
|
|
|
text = models.TextField(u'text opravy',blank = True, help_text='Text opravy')
|
|
|
|
# def __init__(self,dictionary):
|
|
# for k,v in dictionary.items():
|
|
# setattr(self,k,v)
|
|
|
|
def __str__(self):
|
|
return force_unicode(u'%s od %s: %s',self.status,self.autor,self.text)
|
|
|
|
|
|
|
|
@reversion.register(ignore_duplicate_revision=True)
|
|
@python_2_unicode_compatible
|
|
class Komentar(models.Model):
|
|
class Meta:
|
|
db_table = 'komentare'
|
|
verbose_name = u'Komentář k opravě'
|
|
verbose_name_plural = u'Komentáře k opravě'
|
|
ordering = ['cas']
|
|
|
|
#Interní ID
|
|
id = models.AutoField(primary_key = True)
|
|
|
|
cas = models.DateTimeField(u'čas komentáře',default=timezone.now,help_text = 'Čas zadání komentáře')
|
|
|
|
oprava = models.ForeignKey(Oprava)
|
|
# TODO: Změnit na cizí klíč do orgů
|
|
autor = models.TextField(u'autor komentáře',blank = True, help_text='Autor komentáře')
|
|
|
|
text = models.TextField(u'text komentáře',blank = True, help_text='Text komentáře')
|
|
|
|
def __str__(self):
|
|
return force_unicode(u'%s od %s: %s',self.cas,self.autor,self.text)
|
|
|
|
|
|
|
|
|