better __unicode__ names
This commit is contained in:
parent
32d63afd5a
commit
6f10b1a78a
3 changed files with 13 additions and 8 deletions
|
@ -47,7 +47,7 @@ class List(models.Model):
|
||||||
self.ListItem.objects.all().filter(item=item, list=self).delete()
|
self.ListItem.objects.all().filter(item=item, list=self).delete()
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u'%s (%s)' % (self.title, unicode(self.user))
|
return u'%s (%s)' % (self.title, self.user)
|
||||||
|
|
||||||
def editable(self, user):
|
def editable(self, user):
|
||||||
#FIXME: make permissions work
|
#FIXME: make permissions work
|
||||||
|
@ -62,5 +62,5 @@ class ListItem(models.Model):
|
||||||
item = models.ForeignKey('item.Item')
|
item = models.ForeignKey('item.Item')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u'%s in %s' % (unicode(self.item), unicode(self.list))
|
return u'%s in %s' % (self.item, self.list)
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,7 @@ import ox
|
||||||
|
|
||||||
from api.actions import actions
|
from api.actions import actions
|
||||||
|
|
||||||
'''
|
|
||||||
List API
|
|
||||||
'''
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addListItem(request):
|
def addListItem(request):
|
||||||
'''
|
'''
|
||||||
|
@ -45,7 +43,7 @@ def addListItem(request):
|
||||||
item = get_object_or_404_json(models.Item, pk=data['item'])
|
item = get_object_or_404_json(models.Item, pk=data['item'])
|
||||||
if list.editable(request.user):
|
if list.editable(request.user):
|
||||||
list.add(item)
|
list.add(item)
|
||||||
response = json_response(status=200, text='item removed')
|
response = json_response(status=200, text='item added')
|
||||||
else:
|
else:
|
||||||
response = json_response(status=403, text='not allowed')
|
response = json_response(status=403, text='not allowed')
|
||||||
elif 'query' in data:
|
elif 'query' in data:
|
||||||
|
@ -98,7 +96,10 @@ def addList(request):
|
||||||
list.save()
|
list.save()
|
||||||
response = json_response(status=200, text='created')
|
response = json_response(status=200, text='created')
|
||||||
else:
|
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)
|
return render_to_json_response(response)
|
||||||
actions.register(addList)
|
actions.register(addList)
|
||||||
|
|
||||||
|
@ -109,7 +110,8 @@ def editList(request):
|
||||||
{key: value}
|
{key: value}
|
||||||
keys: name, public
|
keys: name, public
|
||||||
return {'status': {'code': int, 'text': string},
|
return {'status': {'code': int, 'text': string},
|
||||||
'data': {}}
|
'data': {}
|
||||||
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
data = json.loads(request.POST['data'])
|
||||||
list = get_object_or_404_json(models.List, pk=data['list'])
|
list = get_object_or_404_json(models.List, pk=data['list'])
|
||||||
|
|
|
@ -30,6 +30,9 @@ class Preference(models.Model):
|
||||||
key = models.CharField(blank=True, max_length=255)
|
key = models.CharField(blank=True, max_length=255)
|
||||||
value = models.TextField(blank=True)
|
value = models.TextField(blank=True)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return u"%s/%s=%s" % (self.user, self.key, self.value)
|
||||||
|
|
||||||
def get_user_json(user):
|
def get_user_json(user):
|
||||||
json = {}
|
json = {}
|
||||||
for key in ('username', ):
|
for key in ('username', ):
|
||||||
|
|
Loading…
Reference in a new issue