X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/f1c6ff102206aa2b0903d61eb648691d5e2e028c..1b97de98f9d2907bedc3dc15ab24b239e895e93e:/apps/catalogue/models/document.py diff --git a/apps/catalogue/models/document.py b/apps/catalogue/models/document.py index 4f084804..ef5a5ccf 100755 --- a/apps/catalogue/models/document.py +++ b/apps/catalogue/models/document.py @@ -10,6 +10,7 @@ from django.conf import settings from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned from django.db import models from django.template.loader import render_to_string +from django.utils.encoding import force_unicode from django.utils.translation import ugettext_lazy as _ from dvcs.models import Ref from organizations.models import Organization @@ -22,7 +23,7 @@ class Document(Ref): owner_user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True) owner_organization = models.ForeignKey(Organization, null=True) - stage = models.CharField(_('stage'), max_length=128, blank=True, default=STAGES[0]) + stage = models.CharField(_('stage'), max_length=128, blank=True, default=STAGES[0][0]) assigned_to = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, related_name='assignments') deleted = models.BooleanField(default=False) tags = models.ManyToManyField(Tag, blank=True) @@ -72,6 +73,8 @@ class Document(Ref): return metadata def can_edit(self, user): + if user.is_superuser: + return True if self.owner_user: return self.owner_user == user else: @@ -86,6 +89,9 @@ class Document(Ref): self.assigned_to = None self.save() + def stage_name(self): + return force_unicode(dict(STAGES)[self.stage]) if self.stage else None + def get_plan(self): try: plan = self.plan_set.get(stage=self.stage)