remotes/origin/endpoint-for-estimation-system-new-4.0
Jesús Espino 2017-05-18 12:28:04 +02:00 committed by Álex Hermida
parent 511bfe403f
commit 30acf40648
3 changed files with 12 additions and 6 deletions

View File

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

View File

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

View File

@ -333,11 +333,11 @@ class GameValidator(validators.ModelValidator):
if not isinstance(roles, list): if not isinstance(roles, list):
raise ValidationError(_("Invalid roles format")) raise ValidationError(_("Invalid roles format"))
for role in roles: for role_id in roles:
if "id" not in role or "name" not in role: if not isinstance(role_id, int):
raise ValidationError(_("Invalid role format")) 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")) raise ValidationError(_("Invalid role for the project"))
return attrs return attrs