diff --git a/pandora/itemlist/models.py b/pandora/itemlist/models.py index b2a58bfad..e116efb6f 100644 --- a/pandora/itemlist/models.py +++ b/pandora/itemlist/models.py @@ -47,7 +47,7 @@ class List(models.Model): self.ListItem.objects.all().filter(item=item, list=self).delete() def __unicode__(self): - return u'%s (%s)' % (self.title, unicode(self.user)) + return u'%s (%s)' % (self.title, self.user) def editable(self, user): #FIXME: make permissions work @@ -62,5 +62,5 @@ class ListItem(models.Model): item = models.ForeignKey('item.Item') def __unicode__(self): - return u'%s in %s' % (unicode(self.item), unicode(self.list)) + return u'%s in %s' % (self.item, self.list) diff --git a/pandora/itemlist/views.py b/pandora/itemlist/views.py index e2d6c70dc..b2d534ef7 100644 --- a/pandora/itemlist/views.py +++ b/pandora/itemlist/views.py @@ -25,9 +25,7 @@ import ox from api.actions import actions -''' - List API -''' + @login_required_json def addListItem(request): ''' @@ -45,7 +43,7 @@ def addListItem(request): item = get_object_or_404_json(models.Item, pk=data['item']) if list.editable(request.user): list.add(item) - response = json_response(status=200, text='item removed') + response = json_response(status=200, text='item added') else: response = json_response(status=403, text='not allowed') elif 'query' in data: @@ -98,7 +96,10 @@ def addList(request): list.save() response = json_response(status=200, text='created') else: - response = json_response(status=403, text='list name exists') + response = json_response(status=200, text='list already exists') + response['data']['errors'] = { + 'name': 'List already exists' + } return render_to_json_response(response) actions.register(addList) @@ -109,7 +110,8 @@ def editList(request): {key: value} keys: name, public return {'status': {'code': int, 'text': string}, - 'data': {}} + 'data': {} + } ''' data = json.loads(request.POST['data']) list = get_object_or_404_json(models.List, pk=data['list']) diff --git a/pandora/user/models.py b/pandora/user/models.py index 768f13b6a..7a3d58e2a 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -30,6 +30,9 @@ class Preference(models.Model): key = models.CharField(blank=True, max_length=255) value = models.TextField(blank=True) + def __unicode__(self): + return u"%s/%s=%s" % (self.user, self.key, self.value) + def get_user_json(user): json = {} for key in ('username', ):