From f8523b7ca20abd3863db4c0d8c911a214a05473a Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 9 Oct 2011 17:53:18 +0200 Subject: [PATCH] add/editEvents --- pandora/event/models.py | 2 +- pandora/event/views.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pandora/event/models.py b/pandora/event/models.py index f9244403a..b471074cf 100644 --- a/pandora/event/models.py +++ b/pandora/event/models.py @@ -79,7 +79,7 @@ class Event(models.Model): def save(self, *args, **kwargs): if not self.name_sort: self.name_sort = self.name - self.name_find = self.name + '||'.join(self.alternativeNames) + self.name_find = '||' + self.name + '||'.join(self.alternativeNames) + '||' super(Event, self).save(*args, **kwargs) def get_id(self): diff --git a/pandora/event/views.py b/pandora/event/views.py index b11016f00..3013e2b7a 100644 --- a/pandora/event/views.py +++ b/pandora/event/views.py @@ -2,6 +2,7 @@ # vi:si:et:sw=4:sts=4:ts=4 from __future__ import division +import ox from ox.utils import json from ox.django.decorators import login_required_json from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response @@ -10,7 +11,7 @@ from api.actions import actions from item import utils import models - +import tasks @login_required_json def addEvent(request): @@ -37,7 +38,9 @@ def addEvent(request): if key in data and data[key]: setattr(event, key, data[key]) event.save() + tasks.update_matches.delay(event.id) response = json_response(status=200, text='created') + response['data'] = event.json() else: response = json_response(status=403, text='name exists') response['data']['names'] = existing_names @@ -57,7 +60,7 @@ def editEvent(request): update provides keys of event with id ''' data = json.loads(request.POST['data']) - event = get_object_or_404_json(models.Event, pk=data['id']) + event = get_object_or_404_json(models.Event, pk=ox.from26(data['id'])) if event.editable(request.user): conflict = False conflict_names = [] @@ -72,6 +75,7 @@ def editEvent(request): if key in data: setattr(event, key, data[key]) event.save() + tasks.update_matches.delay(event.id) response = json_response(status=200, text='updated') else: response = json_response(status=403, text='Event name conflict')