Commit cde39c47 authored by Michal Čihař's avatar Michal Čihař

Add validation for whiteboard messages

Issue #159
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 0d12830c
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
"""Whiteboard model.""" """Whiteboard model."""
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy from django.utils.translation import ugettext_lazy, ugettext as _
from django.core.exceptions import ValidationError
from weblate.lang.models import Language from weblate.lang.models import Language
...@@ -41,3 +42,12 @@ class WhiteboardMessage(models.Model): ...@@ -41,3 +42,12 @@ class WhiteboardMessage(models.Model):
def __unicode__(self): def __unicode__(self):
return self.message return self.message
def clean(self):
if self.project and self.subproject:
if self.subproject.project == self.project:
self.project = None
else:
raise ValidationError(
_('Do not specify both component and project!')
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment