From 1cc795995db11a27539ff1a004df61456726dadf Mon Sep 17 00:00:00 2001 From: j Date: Fri, 19 Feb 2016 22:04:15 +0530 Subject: [PATCH] user.get_profile()->user.profile --- pandora/annotation/models.py | 2 +- pandora/annotation/views.py | 4 ++-- pandora/app/config.py | 2 +- pandora/app/views.py | 2 +- pandora/archive/models.py | 2 +- pandora/archive/views.py | 6 +++--- pandora/clip/managers.py | 2 +- pandora/document/models.py | 2 +- pandora/edit/models.py | 6 +++--- pandora/edit/views.py | 2 +- pandora/entity/models.py | 2 +- pandora/event/models.py | 2 +- pandora/item/managers.py | 6 +++--- pandora/item/models.py | 10 +++++----- pandora/item/views.py | 18 +++++++++--------- pandora/itemlist/models.py | 6 +++--- pandora/itemlist/views.py | 2 +- pandora/news/managers.py | 2 +- pandora/news/models.py | 2 +- pandora/place/models.py | 2 +- pandora/settings.py | 7 ++++--- pandora/text/models.py | 6 +++--- pandora/text/views.py | 6 +++--- pandora/tv/models.py | 3 ++- pandora/user/decorators.py | 2 +- pandora/user/models.py | 14 +++++++------- pandora/user/views.py | 22 +++++++++++----------- 27 files changed, 72 insertions(+), 70 deletions(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index db7d58d34..a8ede67da 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -103,7 +103,7 @@ class Annotation(models.Model): def editable(self, user): if user.is_authenticated(): - if user.get_profile().capability('canEditAnnotations') or \ + if user.profile.capability('canEditAnnotations') or \ self.user == user or \ user.groups.filter(id__in=self.item.groups.all()).count() > 0: return True diff --git a/pandora/annotation/views.py b/pandora/annotation/views.py index 27bbb1fcd..3520bb721 100644 --- a/pandora/annotation/views.py +++ b/pandora/annotation/views.py @@ -170,7 +170,7 @@ def addAnnotation(request, data): layer_id = data['layer'] layer = get_by_id(settings.CONFIG['layers'], layer_id) - if layer['canAddAnnotations'].get(request.user.get_profile().get_level()): + if layer['canAddAnnotations'].get(request.user.profile.get_level()): if layer['type'] == 'entity': try: value = Entity.get_by_name(ox.decode_html(data['value']), layer['entity']).get_id() @@ -229,7 +229,7 @@ def addAnnotations(request, data): layer_id = data['layer'] layer = get_by_id(settings.CONFIG['layers'], layer_id) if item.editable(request.user) \ - and layer['canAddAnnotations'].get(request.user.get_profile().get_level()): + and layer['canAddAnnotations'].get(request.user.profile.get_level()): response = json_response() data['user'] = request.user.username t = add_annotations.delay(data) diff --git a/pandora/app/config.py b/pandora/app/config.py index c82f43a0f..060f661ac 100644 --- a/pandora/app/config.py +++ b/pandora/app/config.py @@ -173,7 +173,7 @@ check the README for further details. try: if User.objects.filter(profile__level=admin).count() == 0: for u in User.objects.filter(is_superuser=True): - p = u.get_profile() + p = u.profile p.level = admin p.save() settings.ADMIN = tuple([(u.username, u.email) diff --git a/pandora/app/views.py b/pandora/app/views.py index 963d76677..8b84ab4d7 100644 --- a/pandora/app/views.py +++ b/pandora/app/views.py @@ -133,7 +133,7 @@ def editPage(request, data): } see: getPage ''' - if request.user.get_profile().capability('canEditSitePages'): + if request.user.profile.capability('canEditSitePages'): page, created = models.Page.objects.get_or_create(name=data['name']) page.text = ox.sanitize_html(data['text']) page.save() diff --git a/pandora/archive/models.py b/pandora/archive/models.py index b0fcf5437..a10dc86a1 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -305,7 +305,7 @@ class File(models.Model): return srt def editable(self, user): - p = user.get_profile() + p = user.profile return p.get_level() in ('admin', 'staff') or \ (not self.available and p.capability('canAddItems')) or \ self.instances.filter(volume__user=user).count() > 0 or \ diff --git a/pandora/archive/views.py b/pandora/archive/views.py index c563c34bb..8780ce907 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -83,7 +83,7 @@ def update(request, data): t = tasks.update_files.delay(user.username, data['volume'], data['files']) response['data']['taskId'] = t.task_id - user_profile = user.get_profile() + user_profile = user.profile user_profile.files_updated = datetime.now() user_profile.save() @@ -179,7 +179,7 @@ def addMedia(request, data): ''' response = json_response({}) oshash = data.pop('id') - if not request.user.get_profile().capability('canAddItems'): + if not request.user.profile.capability('canAddItems'): response = json_response(status=403, text='permission denied') elif models.File.objects.filter(oshash=oshash).count() > 0: f = models.File.objects.get(oshash=oshash) @@ -496,7 +496,7 @@ def removeMedia(request, data): see: addMedia, editMedia, findMedia, moveMedia ''' response = json_response() - if request.user.get_profile().get_level() == 'admin': + if request.user.profile.get_level() == 'admin': qs = models.File.objects.filter(oshash__in=data['ids'], instances__id=None) selected = set([f.item.id for f in qs if f.selected]) items = list(set([f.item.id for f in qs])) diff --git a/pandora/clip/managers.py b/pandora/clip/managers.py index 65ff43bfb..728d50a12 100644 --- a/pandora/clip/managers.py +++ b/pandora/clip/managers.py @@ -219,7 +219,7 @@ class ClipManager(Manager): qs = qs.filter(sort__rightslevel__lte=allowed_level) #users can see public clips, there own clips and clips of there groups else: - allowed_level = settings.CONFIG['capabilities']['canSeeItem'][user.get_profile().get_level()] + allowed_level = settings.CONFIG['capabilities']['canSeeItem'][user.profile.get_level()] q = Q(sort__rightslevel__lte=allowed_level)|Q(user=user.id) if user.groups.count(): q |= Q(item__groups__in=user.groups.all()) diff --git a/pandora/document/models.py b/pandora/document/models.py index f92cb2375..9115eb501 100644 --- a/pandora/document/models.py +++ b/pandora/document/models.py @@ -103,7 +103,7 @@ class Document(models.Model): return False if self.user == user or \ user.is_staff or \ - user.get_profile().capability('canEditDocuments') == True or \ + user.profile.capability('canEditDocuments') == True or \ (item and item.editable(user)): return True return False diff --git a/pandora/edit/models.py b/pandora/edit/models.py index f67068bcf..d1945926a 100644 --- a/pandora/edit/models.py +++ b/pandora/edit/models.py @@ -131,7 +131,7 @@ class Edit(models.Model): return False if self.user == user or \ user.is_staff or \ - user.get_profile().capability('canEditFeaturedEdits') == True: + user.profile.capability('canEditFeaturedEdits') == True: return True return False @@ -151,7 +151,7 @@ class Edit(models.Model): pos.section = 'personal' pos.save() elif value == 'featured': - if user.get_profile().capability('canEditFeaturedEdits'): + if user.profile.capability('canEditFeaturedEdits'): pos, created = Position.objects.get_or_create(edit=self, user=user, section='featured') if created: @@ -527,7 +527,7 @@ class Position(models.Model): edit = models.ForeignKey(Edit, related_name='position') user = models.ForeignKey(User, related_name='edit_position') - section = models.CharField(max_length='255') + section = models.CharField(max_length=255) position = models.IntegerField(default=0) def __unicode__(self): diff --git a/pandora/edit/views.py b/pandora/edit/views.py index 338d6bc45..413e4c2f2 100644 --- a/pandora/edit/views.py +++ b/pandora/edit/views.py @@ -491,7 +491,7 @@ def sortEdits(request, data): }.get(section,section) #ids = list(set(data['ids'])) ids = data['ids'] - if section == 'featured' and not request.user.get_profile().capability('canEditFeaturedEdits'): + if section == 'featured' and not request.user.profile.capability('canEditFeaturedEdits'): response = json_response(status=403, text='not allowed') else: user = request.user diff --git a/pandora/entity/models.py b/pandora/entity/models.py index 6ab3ea542..90bf44eb7 100644 --- a/pandora/entity/models.py +++ b/pandora/entity/models.py @@ -102,7 +102,7 @@ class Entity(models.Model): if not user or user.is_anonymous(): return False if user.is_staff or \ - user.get_profile().capability('canEditEntities') == True or \ + user.profile.capability('canEditEntities') == True or \ (item and item.editable(user)): return True return False diff --git a/pandora/event/models.py b/pandora/event/models.py index faa57ac8d..4bf951f47 100644 --- a/pandora/event/models.py +++ b/pandora/event/models.py @@ -74,7 +74,7 @@ class Event(models.Model): if user and not user.is_anonymous() \ and (not self.user or \ self.user == user or \ - user.get_profile().capability('canEditEvents')): + user.profile.capability('canEditEvents')): return True return False diff --git a/pandora/item/managers.py b/pandora/item/managers.py index e6390d95e..485f11edc 100644 --- a/pandora/item/managers.py +++ b/pandora/item/managers.py @@ -98,7 +98,7 @@ def parseCondition(condition, user, owner=None): if (not exclude and op == '=' or op in ('$', '^')) and v == '': return Q() elif k == 'filename' and (user.is_anonymous() or \ - not user.get_profile().capability('canSeeMedia')): + not user.profile.capability('canSeeMedia')): return Q(id=0) elif k == 'oshash': return Q(files__oshash=v) @@ -117,7 +117,7 @@ def parseCondition(condition, user, owner=None): q = ~q return q elif k in ('canplayvideo', 'canplayclips'): - level = user.is_anonymous() and 'guest' or user.get_profile().get_level() + level = user.is_anonymous() and 'guest' or user.profile.get_level() allowed_level = settings.CONFIG['capabilities'][{ 'canplayvideo': 'canPlayVideo', 'canplayclips': 'canPlayClips' @@ -326,7 +326,7 @@ class ItemManager(Manager): rendered_q = Q(rendered=True) #users can see public items, there own items and items of there groups else: - level = user.get_profile().get_level() + level = user.profile.get_level() allowed_level = settings.CONFIG['capabilities']['canSeeItem'][level] q = Q(level__lte=allowed_level)|Q(user=user) rendered_q = Q(rendered=True)|Q(user=user) diff --git a/pandora/item/models.py b/pandora/item/models.py index 11c1a7cd2..0fa593322 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -206,7 +206,7 @@ class Item(models.Model): if user.is_anonymous(): level = 'guest' else: - level = user.get_profile().get_level() + level = user.profile.get_level() editable = self.editable(user) if editable: return True @@ -220,7 +220,7 @@ class Item(models.Model): def editable(self, user): if user.is_anonymous(): return False - if user.get_profile().capability('canEditMetadata') == True or \ + if user.profile.capability('canEditMetadata') == True or \ user.is_staff or \ self.user == user or \ self.groups.filter(id__in=user.groups.all()).count() > 0: @@ -346,7 +346,7 @@ class Item(models.Model): update_ids = False if not self.id: if self.user: - self.level = settings.CONFIG['rightsLevel'][self.user.get_profile().get_level()] + self.level = settings.CONFIG['rightsLevel'][self.user.profile.get_level()] else: self.level = settings.CONFIG['rightsLevel']['member'] if not self.public_id: @@ -1139,7 +1139,7 @@ class Item(models.Model): def get_files(self, user): files = self.files.all().select_related() - if user.get_profile().get_level() != 'admin': + if user.profile.get_level() != 'admin': files = files.filter(instances__volume__user=user) return [f.json() for f in files] @@ -1779,7 +1779,7 @@ class Description(models.Model): class AnnotationSequence(models.Model): - item = models.ForeignKey('Item', related_name='_annotation_sequence', unique=True) + item = models.OneToOneField('Item', related_name='_annotation_sequence') value = models.BigIntegerField(default=1) @classmethod diff --git a/pandora/item/views.py b/pandora/item/views.py index cd26ba988..f728286cd 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -504,7 +504,7 @@ def add(request, data): notes: To allow for this, set config option `itemRequiresVideo` to false. see: edit, find, get, lookup, remove, upload ''' - if not request.user.get_profile().capability('canAddItems'): + if not request.user.profile.capability('canAddItems'): response = json_response(status=403, text='permission denied') else: data['title'] = data.get('title', 'Untitled') @@ -542,13 +542,13 @@ def edit(request, data): if item.editable(request.user): response = json_response(status=200, text='ok') if 'rightslevel' in data: - if request.user.get_profile().capability('canEditRightsLevel') == True: + if request.user.profile.capability('canEditRightsLevel') == True: item.level = int(data['rightslevel']) else: response = json_response(status=403, text='permission denied') del data['rightslevel'] if 'user' in data: - if request.user.get_profile().get_level() in ('admin', 'staff') and \ + if request.user.profile.get_level() in ('admin', 'staff') and \ models.User.objects.filter(username=data['user']).exists(): new_user = models.User.objects.get(username=data['user']) if new_user != item.user: @@ -556,7 +556,7 @@ def edit(request, data): update_clips = True del data['user'] if 'groups' in data: - if not request.user.get_profile().capability('canManageUsers'): + if not request.user.profile.capability('canManageUsers'): # Users wihtout canManageUsers can only add/remove groups they are not in groups = set([g.name for g in item.groups.all()]) user_groups = set([g.name for g in request.user.groups.all()]) @@ -588,7 +588,7 @@ def remove(request, data): response = json_response({}) item = get_object_or_404_json(models.Item, public_id=data['id']) user = request.user - if user.get_profile().capability('canRemoveItems') == True or \ + if user.profile.capability('canRemoveItems') == True or \ user.is_staff or \ item.user == user or \ item.groups.filter(id__in=user.groups.all()).count() > 0: @@ -1016,7 +1016,7 @@ def atom_xml(request): level = settings.CONFIG['capabilities']['canSeeItem']['guest'] if not request.user.is_anonymous(): - level = request.user.get_profile().level + level = request.user.profile.level for item in models.Item.objects.filter(level__lte=level, rendered=True).order_by('-created')[:7]: if add_updated: updated = ET.SubElement(feed, "updated") @@ -1185,7 +1185,7 @@ def sitemap_xml(request): def item_json(request, id): level = settings.CONFIG['capabilities']['canSeeItem']['guest'] if not request.user.is_anonymous(): - level = request.user.get_profile().level + level = request.user.profile.level qs = models.Item.objects.filter(public_id=id, level__lte=level) if qs.count() == 0: response = json_response(status=404, text='not found') @@ -1198,7 +1198,7 @@ def item_json(request, id): def item_xml(request, id): level = settings.CONFIG['capabilities']['canSeeItem']['guest'] if not request.user.is_anonymous(): - level = request.user.get_profile().level + level = request.user.profile.level qs = models.Item.objects.filter(public_id=id, level__lte=level) if qs.count() == 0: response = json_response(status=404, text='not found') @@ -1237,7 +1237,7 @@ def item(request, id): template = 'index.html' level = settings.CONFIG['capabilities']['canSeeItem']['guest'] if not request.user.is_anonymous(): - level = request.user.get_profile().level + level = request.user.profile.level qs = models.Item.objects.filter(public_id=id, level__lte=level) if qs.count() == 0: context = RequestContext(request, { diff --git a/pandora/itemlist/models.py b/pandora/itemlist/models.py index da66953d8..c387468c0 100644 --- a/pandora/itemlist/models.py +++ b/pandora/itemlist/models.py @@ -112,7 +112,7 @@ class List(models.Model): return False if self.user == user or \ user.is_staff or \ - user.get_profile().capability('canEditFeaturedLists') == True: + user.profile.capability('canEditFeaturedLists') == True: return True return False @@ -143,7 +143,7 @@ class List(models.Model): pos.section = 'personal' pos.save() elif value == 'featured': - if user.get_profile().capability('canEditFeaturedLists'): + if user.profile.capability('canEditFeaturedLists'): pos, created = Position.objects.get_or_create(list=self, user=user, section='featured') if created: @@ -301,7 +301,7 @@ class Position(models.Model): list = models.ForeignKey(List, related_name='position') user = models.ForeignKey(User) - section = models.CharField(max_length='255') + section = models.CharField(max_length=255) position = models.IntegerField(default=0) def __unicode__(self): diff --git a/pandora/itemlist/views.py b/pandora/itemlist/views.py index ef0b55474..6696a03e8 100644 --- a/pandora/itemlist/views.py +++ b/pandora/itemlist/views.py @@ -394,7 +394,7 @@ def sortLists(request, data): }.get(section,section) #ids = list(set(data['ids'])) ids = data['ids'] - if section == 'featured' and not request.user.get_profile().capability('canEditFeaturedLists'): + if section == 'featured' and not request.user.profile.capability('canEditFeaturedLists'): response = json_response(status=403, text='not allowed') else: user = request.user diff --git a/pandora/news/managers.py b/pandora/news/managers.py index 89bb82cdb..acf045154 100644 --- a/pandora/news/managers.py +++ b/pandora/news/managers.py @@ -114,7 +114,7 @@ class NewsManager(Manager): if conditions: qs = qs.filter(conditions) if user: - if not user.get_profile().get_level() in ('staff', 'admin'): + if not user.profile.get_level() in ('staff', 'admin'): qs = qs.filter(Q(public=True)|Q(user=user)) else: qs = qs.filter(public=True) diff --git a/pandora/news/models.py b/pandora/news/models.py index 77d371b01..d01737419 100644 --- a/pandora/news/models.py +++ b/pandora/news/models.py @@ -19,7 +19,7 @@ class News(models.Model): text = models.TextField() def editable(self, user): - return user.is_authenticated() and user.get_profile().capability("canEditSitePages") + return user.is_authenticated() and user.profile.capability("canEditSitePages") def save(self, *args, **kwargs): super(News, self).save(*args, **kwargs) diff --git a/pandora/place/models.py b/pandora/place/models.py index 3ae0559ca..9de33c10c 100644 --- a/pandora/place/models.py +++ b/pandora/place/models.py @@ -68,7 +68,7 @@ class Place(models.Model): if user and not user.is_anonymous() \ and (not self.user or \ self.user == user or \ - user.get_profile().capability('canEditPlaces')): + user.profile.capability('canEditPlaces')): return True return False diff --git a/pandora/settings.py b/pandora/settings.py index efa2da1b4..8c6610154 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -108,9 +108,7 @@ INSTALLED_APPS = ( # 'django.contrib.admindocs', 'django.contrib.humanize', - 'django_extensions', - 'devserver', - 'south', + #'django_extensions', 'djcelery', 'app', 'log', @@ -246,3 +244,6 @@ except NameError: Exception('Please create a %s file with random characters to generate your secret key!' % SECRET_FILE) INSTALLED_APPS = tuple(list(INSTALLED_APPS) + LOCAL_APPS) + +ALLOWED_HOSTS = ['*'] + diff --git a/pandora/text/models.py b/pandora/text/models.py index 90ca5711c..3c3504a99 100644 --- a/pandora/text/models.py +++ b/pandora/text/models.py @@ -84,7 +84,7 @@ class Text(models.Model): return False if self.user == user or \ user.is_staff or \ - user.get_profile().capability('canEditFeaturedTexts') == True: + user.profile.capability('canEditFeaturedTexts') == True: return True return False @@ -104,7 +104,7 @@ class Text(models.Model): pos.section = 'personal' pos.save() elif value == 'featured': - if user.get_profile().capability('canEditFeaturedTexts'): + if user.profile.capability('canEditFeaturedTexts'): pos, created = Position.objects.get_or_create(text=self, user=user, section='featured') if created: @@ -305,7 +305,7 @@ class Position(models.Model): text = models.ForeignKey(Text, related_name='position') user = models.ForeignKey(User, related_name='text_position') - section = models.CharField(max_length='255') + section = models.CharField(max_length=255) position = models.IntegerField(default=0) def __unicode__(self): diff --git a/pandora/text/views.py b/pandora/text/views.py index 0855d071d..81b70ca63 100644 --- a/pandora/text/views.py +++ b/pandora/text/views.py @@ -99,7 +99,7 @@ def getText(request, data): 'name': '', 'text': '', 'type': 'html', - 'editable': not request.user.is_anonymous() and request.user.get_profile().capability('canEditFeaturedTexts') + 'editable': not request.user.is_anonymous() and request.user.profile.capability('canEditFeaturedTexts') } else: text = qs[0] @@ -140,7 +140,7 @@ def editText(request, data): else: qs = models.Text.objects.filter(name='') if qs.count() == 0: - if request.user.get_profile().capability('canEditFeaturedTexts'): + if request.user.profile.capability('canEditFeaturedTexts'): text = models.Text(name='', user=request.user) text.save() else: @@ -331,7 +331,7 @@ def sortTexts(request, data): }.get(section,section) #ids = list(set(data['ids'])) ids = data['ids'] - if section == 'featured' and not request.user.get_profile().capability('canEditFeaturedTexts'): + if section == 'featured' and not request.user.profile.capability('canEditFeaturedTexts'): response = json_response(status=403, text='not allowed') else: user = request.user diff --git a/pandora/tv/models.py b/pandora/tv/models.py index dc401229e..36d0d4248 100644 --- a/pandora/tv/models.py +++ b/pandora/tv/models.py @@ -16,7 +16,8 @@ class Channel(models.Model): modified = models.DateTimeField(auto_now=True) run = models.IntegerField(default=0) - list = models.ForeignKey('itemlist.List', related_name='channel', null=True, unique=True, blank=True) + list = models.OneToOneField('itemlist.List', related_name='channel', null=True, blank=True) + #list = models.ForeignKey('itemlist.List', related_name='channel', null=True, unique=True, blank=True) def __unicode__(self): return u"%s %s" % (self.list or 'All', self.run) diff --git a/pandora/user/decorators.py b/pandora/user/decorators.py index 4a11ddebb..2629ba75d 100644 --- a/pandora/user/decorators.py +++ b/pandora/user/decorators.py @@ -10,7 +10,7 @@ def capability_required_json(capability): def capability_required(function=None): def _wrapped_view(request, *args, **kwargs): if request.user.is_authenticated() and \ - request.user.get_profile().capability(capability): + request.user.profile.capability(capability): return function(request, *args, **kwargs) return render_to_json_response(json_response(status=403, text='permission denied')) return wraps(function)(_wrapped_view) diff --git a/pandora/user/models.py b/pandora/user/models.py index 384c597ef..c0a0777c8 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -23,7 +23,7 @@ import tasks class SessionData(models.Model): session_key = models.CharField(max_length=40, primary_key=True) - user = models.ForeignKey(User, unique=True, null=True, blank=True, related_name='data') + user = models.OneToOneField(User, null=True, blank=True, related_name='data') firstseen = models.DateTimeField(auto_now_add=True, db_index=True) lastseen = models.DateTimeField(default=datetime.now, db_index=True) username = models.CharField(max_length=255, null=True, db_index=True) @@ -87,7 +87,7 @@ class SessionData(models.Model): def save(self, *args, **kwargs): if self.user: self.username = self.user.username - self.level = self.user.get_profile().level + self.level = self.user.profile.level self.firstseen = self.user.date_joined if self.user.groups.exists(): self.groupssort = ''.join([g.name for g in self.user.groups.all()]) @@ -160,7 +160,7 @@ class SessionData(models.Model): 'windowsize': self.windowsize, } if self.user: - p = self.user.get_profile() + p = self.user.profile j['disabled'] = not self.user.is_active j['email'] = self.user.email j['groups'] = [g.name for g in self.user.groups.all()] @@ -176,7 +176,7 @@ class SessionData(models.Model): class UserProfile(models.Model): reset_code = models.CharField(max_length=255, blank=True, null=True, unique=True) - user = models.ForeignKey(User, unique=True, related_name='profile') + user = models.OneToOneField(User, related_name='profile') level = models.IntegerField(default=1) files_updated = models.DateTimeField(default=datetime.now) @@ -343,7 +343,7 @@ def init_user(user, request=None): result = settings.CONFIG['user'].copy() result['ui'] = get_ui(json.loads(request.session.get('ui', '{}'))) else: - profile = user.get_profile() + profile = user.profile result = {} for key in ('username', ): result[key] = getattr(user, key) @@ -357,7 +357,7 @@ def init_user(user, request=None): return result def user_json(user, keys=None): - p = user.get_profile() + p = user.profile j = { 'disabled': not user.is_active, 'email': user.email, @@ -381,7 +381,7 @@ def has_capability(user, capability): if user.is_anonymous(): level = 'guest' else: - level = user.get_profile().get_level() + level = user.profile.get_level() return level in settings.CONFIG['capabilities'][capability] \ and settings.CONFIG['capabilities'][capability][level] diff --git a/pandora/user/views.py b/pandora/user/views.py index 0ddebd573..767f6e975 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -116,7 +116,7 @@ def signout(request, data): response = json_response(text='ok') if request.user.is_authenticated(): uid = request.user.id - profile = request.user.get_profile() + profile = request.user.profile if profile.ui.get('page') == 'signout': profile.ui['page'] = '' profile.save() @@ -201,7 +201,7 @@ def signup(request, data): user = authenticate(username=data['username'], password=data['password']) if ui: - profile = user.get_profile() + profile = user.profile profile.ui = ui profile.save() @@ -245,7 +245,7 @@ def resetPassword(request, data): user = qs[0].user user.set_password(data['password']) user.save() - user_profile = user.get_profile() + user_profile = user.profile user_profile.reset_code = None user_profile.save() user = authenticate(username=user.username, password=data['password']) @@ -301,7 +301,7 @@ def requestToken(request, data): ox.fromAZ('AAAAAAAAAAAAAAAAA'))) if models.UserProfile.objects.filter(reset_code=code).count() == 0: break - user_profile = user.get_profile() + user_profile = user.profile user_profile.reset_code = code user_profile.save() @@ -349,7 +349,7 @@ def editUser(request, data): response = json_response() user = get_object_or_404_json(User, pk=ox.fromAZ(data['id'])) - profile = user.get_profile() + profile = user.profile if 'disabled' in data: user.is_active = not data['disabled'] if 'email' in data: @@ -567,7 +567,7 @@ def mail(request, data): see: contact ''' response = json_response() - p = request.user.get_profile() + p = request.user.profile if p.capability('canSendMail'): email_from = '"%s" <%s>' % (settings.SITENAME, settings.CONFIG['site']['email']['system']) headers = { @@ -707,14 +707,14 @@ def editPreferences(request, data): change = True request.user.email = ox.escape_html(data['email']) if 'newsletter' in data: - profile = request.user.get_profile() + profile = request.user.profile profile.newsletter = data['newsletter'] profile.save() if 'password' in data: change = True request.user.set_password(data['password']) if 'script' in data: - profile = request.user.get_profile() + profile = request.user.profile profile.preferences['script'] = data['script'] profile.save() if change: @@ -727,7 +727,7 @@ actions.register(editPreferences, cache=False) def reset_ui(request): if request.user.is_authenticated(): - profile = request.user.get_profile() + profile = request.user.profile profile.ui = {} profile.save() else: @@ -744,7 +744,7 @@ def resetUI(request, data): ''' response = json_response() if request.user.is_authenticated(): - profile = request.user.get_profile() + profile = request.user.profile profile.ui = {} profile.save() else: @@ -765,7 +765,7 @@ def setUI(request, data): see: resetUI ''' if request.user.is_authenticated(): - profile = request.user.get_profile() + profile = request.user.profile ui = profile.ui else: ui = json.loads(request.session.get('ui', '{}'))