diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2014-05-04 07:59:26 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2014-05-04 07:59:26 (GMT) |
commit | 0684b55b5f66da1c2dc61f15105ef5e0632019bf (patch) | |
tree | 848a31a82345dd38643c4be76620fe3f16f52adf /sugar_network/db/routes.py | |
parent | a57e9537c034ee4566f8cf694518619588097f76 (diff) |
Simplify code and return author property as-is
Diffstat (limited to 'sugar_network/db/routes.py')
-rw-r--r-- | sugar_network/db/routes.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/sugar_network/db/routes.py b/sugar_network/db/routes.py index 4c29780..29507d3 100644 --- a/sugar_network/db/routes.py +++ b/sugar_network/db/routes.py @@ -19,7 +19,7 @@ import logging from contextlib import contextmanager from sugar_network import toolkit -from sugar_network.db.metadata import Aggregated +from sugar_network.db.metadata import Aggregated, Author from sugar_network.toolkit.router import ACL, File from sugar_network.toolkit.router import route, fallbackroute, preroute from sugar_network.toolkit.coroutine import this @@ -46,7 +46,7 @@ class Routes(object): doc.created() if this.principal: authors = doc.posts['author'] = {} - self._useradd(authors, this.principal, ACL.ORIGINAL) + self._useradd(authors, this.principal, Author.ORIGINAL) self.volume[this.request.resource].create(doc.posts) return doc['guid'] @@ -238,19 +238,14 @@ class Routes(object): user_doc = self.volume['user'][user] if user_doc.available: props['name'] = user_doc['name'] - role |= ACL.INSYSTEM + role |= Author.INSYSTEM else: - role &= ~ACL.INSYSTEM - props['role'] = role & (ACL.INSYSTEM | ACL.ORIGINAL) + role &= ~Author.INSYSTEM + props['role'] = role & (Author.INSYSTEM | Author.ORIGINAL) if user in authors: authors[user].update(props) else: - if authors: - top = max(authors.values(), key=lambda x: x['order']) - props['order'] = top['order'] + 1 - else: - props['order'] = 0 authors[user] = props def _aggpost(self, acl): @@ -282,7 +277,7 @@ class Routes(object): if this.principal: authors = aggvalue['author'] = {} - role = ACL.ORIGINAL if this.principal in doc['author'] else 0 + role = Author.ORIGINAL if this.principal in doc['author'] else 0 self._useradd(authors, this.principal, role) doc.posts[request.prop] = {aggid: aggvalue} doc.updated() |