remotes/origin/endpoint-for-estimation-system
Jesús Espino 2017-05-18 12:28:04 +02:00
parent ea0be9b119
commit 39d5fe3ce4
3 changed files with 12 additions and 6 deletions

View File

@ -34,6 +34,7 @@ watched_types = set([
"tasks.task",
"wiki.wiki_page",
"milestones.milestone",
"projects.game",
])
@ -75,8 +76,11 @@ def emit_event_for_model(obj, *, type:str="change", channel:str="events",
projectid = getattr(obj, "project_id")
pk = getattr(obj, "pk", None)
app_name, model_name = content_type.split(".", 1)
routing_key = "changes.project.{0}.{1}".format(projectid, app_name)
if hasattr(obj, '_event_tag'):
event_tag = obj._event_tag
else:
event_tag, model_name = content_type.split(".", 1)
routing_key = "changes.project.{0}.{1}".format(projectid, event_tag)
data = {"type": type,
"matches": content_type,

View File

@ -1147,6 +1147,8 @@ class Game(models.Model):
userstories = JSONField()
scales = JSONField()
roles = JSONField()
_importing = None
_event_tag = "games"
def save(self, *args, **kwargs):
if not self.uuid:

View File

@ -314,11 +314,11 @@ class GameValidator(validators.ModelValidator):
if not isinstance(roles, list):
raise ValidationError(_("Invalid roles format"))
for role in roles:
if "id" not in role or "name" not in role:
raise ValidationError(_("Invalid role format"))
for role_id in roles:
if not isinstance(role_id, int):
raise ValidationError(_("Invalid role id format"))
if project.roles.filter(id=role['id']).count() == 0:
if project.roles.filter(id=role_id).count() == 0:
raise ValidationError(_("Invalid role for the project"))
return attrs