Skip to content

Commit

Permalink
fix to created_at
Browse files Browse the repository at this point in the history
  • Loading branch information
A. Tapekhin committed Oct 10, 2016
1 parent 75b0d20 commit 1087037
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 182 deletions.
94 changes: 47 additions & 47 deletions docs/ver1_0.apib

Large diffs are not rendered by default.

94 changes: 47 additions & 47 deletions docs/ver2_0.apib

Large diffs are not rendered by default.

61 changes: 32 additions & 29 deletions lingvodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ def configure_routes(config):
# Future note: PUT & DELETE should work on-server only.
config.add_route(name='perspective',
pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}/'
'perspective/{perspective_client_id}/{perspective_id}',
'perspective/{perspective_client_id}/{perspective_object_id}',
factory='lingvodoc.models.ApproveAllAcl') # tested
config.add_route(name='perspective_outside',
pattern='perspective/{perspective_client_id}/{perspective_id}',
pattern='perspective/{perspective_client_id}/{perspective_object_id}',
factory='lingvodoc.models.ApproveAllAcl') # tested
# API #POST
# creates hash in metadata on objects
config.add_route(name='perspective_hash',
pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}/'
'perspective/{perspective_client_id}/{perspective_id}/hash',
'perspective/{perspective_client_id}/{perspective_object_id}/hash',
factory='lingvodoc.models.ApproveAllAcl') # TODO: ?test? only was used one time

config.add_route(name='dangerous_perspectives_hash',
Expand All @@ -189,22 +189,25 @@ def configure_routes(config):
# }
config.add_route(name='perspective_meta',
pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}/'
'perspective/{perspective_client_id}/{perspective_id}/meta',
'perspective/{perspective_client_id}/{perspective_object_id}/meta',
factory='lingvodoc.models.ApproveAllAcl') # tested

config.add_route(name='perspective_tree',
pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}/'
'perspective/{perspective_client_id}/{perspective_id}/tree',
'perspective/{perspective_client_id}/{perspective_object_id}/tree',
factory='lingvodoc.models.ApproveAllAcl') # tested (?)
config.add_route(name='perspective_outside_tree',
pattern='perspective/{perspective_client_id}/{perspective_id}/tree',
pattern='perspective/{perspective_client_id}/{perspective_object_id}/tree',
factory='lingvodoc.models.ApproveAllAcl') # tested (?)

config.add_route(name='perspective_info',
pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}/'
'perspective/{perspective_client_id}/{perspective_id}/info',
'perspective/{perspective_client_id}/{perspective_object_id}/info',
factory='lingvodoc.models.ApproveAllAcl')

# config.add_route(name='test',
# pattern='/test',
# factory='lingvodoc.models.ApproveAllAcl') # tested
# API #POST
# Creating perspective
config.add_route(name='create_perspective',
Expand All @@ -229,14 +232,14 @@ def configure_routes(config):
# roles and users that they are assigned.
config.add_route(name='perspective_roles',
pattern='/dictionary/{client_id}/{object_id}/'
'perspective/{perspective_client_id}/{perspective_id}/roles',
'perspective/{perspective_client_id}/{perspective_object_id}/roles',
factory='lingvodoc.models.ApproveAllAcl')

# API #GET && PUT
# Get or change visibility state for perspective. States are: 'frozen', 'WiP', 'published'
config.add_route(name='perspective_status',
pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/state',
'/perspective/{perspective_client_id}/{perspective_object_id}/state',
factory='lingvodoc.models.ApproveAllAcl') # tested

# API #GET && POST && DELETE
Expand All @@ -262,7 +265,7 @@ def configure_routes(config):
# status: <enabled|disabled>}, contains: [{}], group: <grouping_button_localization_str>]
config.add_route(name='perspective_fields',
pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/fields',
'/perspective/{perspective_client_id}/{perspective_object_id}/fields',
factory='lingvodoc.models.ApproveAllAcl') # tested (except delete, because it not used anywhere(?))

config.add_route(name='create_field',
Expand Down Expand Up @@ -312,7 +315,7 @@ def configure_routes(config):
config.add_route(name='get_entity_indict', pattern='/dictionary/'
'{dictionary_client_id}/{dictionary_object_id}'
'/perspective/'
'{perspective_client_id}/{perspective_id}/'
'{perspective_client_id}/{perspective_object_id}/'
'lexical_entry/'
'{lexical_entry_client_id}/{lexical_entry_object_id}/'
'entity/'
Expand All @@ -332,7 +335,7 @@ def configure_routes(config):
config.add_route(name='get_connected_words_indict', pattern='/dictionary/'
'{dictionary_client_id}/{dictionary_object_id}'
'/perspective/'
'{perspective_client_id}/{perspective_id}/'
'{perspective_client_id}/{perspective_object_id}/'
'lexical_entry/'
'{client_id}/{object_id}/'
'connected',
Expand All @@ -345,7 +348,7 @@ def configure_routes(config):
config.add_route(name='add_group_indict', pattern='/dictionary/'
'{dictionary_client_id}/{dictionary_object_id}'
'/perspective/'
'{perspective_client_id}/{perspective_id}/'
'{perspective_client_id}/{perspective_object_id}/'
'lexical_entry/'
'connect',
factory='lingvodoc.models.ApproveAllAcl') # tested
Expand Down Expand Up @@ -375,44 +378,44 @@ def configure_routes(config):
# no parameters needed.
# ids are returned.
config.add_route(name='create_lexical_entry', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/'
'/perspective/{perspective_client_id}/{perspective_object_id}/'
'lexical_entry',
factory='lingvodoc.models.ApproveAllAcl') # tested

config.add_route(name='create_lexical_entry_bulk', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/'
'/perspective/{perspective_client_id}/{perspective_object_id}/'
'lexical_entries',
factory='lingvodoc.models.ApproveAllAcl') # tested

# API #POST
# {'entity_type': <entity_type>, 'content': <content>, 'locale_id': <locale_id>, 'metadata': <metadata>}
# ids are returned
config.add_route(name='create_entity', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/'
'/perspective/{perspective_client_id}/{perspective_object_id}/'
'lexical_entry/{lexical_entry_client_id}/'
'{lexical_entry_object_id}/entity',
factory='lingvodoc.models.ApproveAllAcl') # tested

config.add_route(name='create_entities_bulk', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/entities',
'/perspective/{perspective_client_id}/{perspective_object_id}/entities',
factory='lingvodoc.models.ApproveAllAcl') # TODO: test

# API #GET
# params: start_from=M, count=N, sort_by=<entity_type>
config.add_route(name='lexical_entries_all', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/all',
'/perspective/{perspective_client_id}/{perspective_object_id}/all',
factory='lingvodoc.models.ApproveAllAcl')

config.add_route(name='lexical_entries_all_count', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/all_count',
'/perspective/{perspective_client_id}/{perspective_object_id}/all_count',
factory='lingvodoc.models.ApproveAllAcl') # tested

config.add_route(name='lexical_entries_published', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/published',
'/perspective/{perspective_client_id}/{perspective_object_id}/published',
factory='lingvodoc.models.ApproveAllAcl')

config.add_route(name='lexical_entries_published_count', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/published_count',
'/perspective/{perspective_client_id}/{perspective_object_id}/published_count',
factory='lingvodoc.models.ApproveAllAcl')
# made only return list of ids, because another route fol full info exist

Expand All @@ -421,34 +424,34 @@ def configure_routes(config):
config.add_route(name='lexical_entry', pattern='/lexical_entry/{client_id}/{object_id}',
factory='lingvodoc.models.ApproveAllAcl') # tested
config.add_route(name='lexical_entry_in_perspective', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/'
'/perspective/{perspective_client_id}/{perspective_object_id}/'
'lexical_entry/{client_id}/{object_id}',
factory='lingvodoc.models.ApproveAllAcl') # tested
# API #PATCH
# Publishers view: this can approve word versions.
# "type": "leveloneentity", "leveltwoentity"
# {"entity": [{"type": <object_type>, "client_id": <client_id>, "object_id": <object_id>}, ] }
config.add_route(name='approve_entity', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/approve',
'/perspective/{perspective_client_id}/{perspective_object_id}/approve',
factory='lingvodoc.models.ApproveAllAcl')
# todo: DANGEROUS! Anyone can approve, if the have their own dictionary and know ids of entity, they want to approve
# todo: fix this
config.add_route(name='approve_all', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/approve_all',
'/perspective/{perspective_client_id}/{perspective_object_id}/approve_all',
factory='lingvodoc.models.ApproveAllAcl')
config.add_route(name='approve_all_outer', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/approve_all_outer',
'/perspective/{perspective_client_id}/{perspective_object_id}/approve_all_outer',
factory='lingvodoc.models.ApproveAllAcl') # TODO: test

# web-view
config.add_route(name='edit_dictionary', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/edit')
'/perspective/{perspective_client_id}/{perspective_object_id}/edit')
# web-view
config.add_route(name='view_dictionary', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/view')
'/perspective/{perspective_client_id}/{perspective_object_id}/view')
# web-view
config.add_route(name='publish_dictionary', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}/publish')
'/perspective/{perspective_client_id}/{perspective_object_id}/publish')

# Merge can be two kinds:
# 1. Dictionaries merge
Expand Down Expand Up @@ -550,7 +553,7 @@ def configure_routes(config):
# [{"id": <userid>, "login": <login>, "name": <name>, "intl_name": <international_name>, "userpic": <url_to_userpic>}, ]
config.add_route(name='dictionary_authors', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}') # TODO: do it
config.add_route(name='perspective_authors', pattern='/dictionary/{dictionary_client_id}/{dictionary_object_id}'
'/perspective/{perspective_client_id}/{perspective_id}') # TODO: just do it
'/perspective/{perspective_client_id}/{perspective_object_id}') # TODO: just do it

# API #GET
# This methods gets info about user by his client_id
Expand Down
17 changes: 9 additions & 8 deletions lingvodoc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class CreatedAtMixin(object):
"""
It's used for automatically set created_at column.
"""
created_at = Column(TIMESTAMP, default=datetime.datetime.utcnow().timestamp(), nullable=False)
created_at = Column(TIMESTAMP, default=datetime.datetime.utcnow(), nullable=False)


class IdMixin(object):
Expand Down Expand Up @@ -724,6 +724,7 @@ class PublishingEntity(Base, TableNameMixin, CreatedAtMixin):
object_id = Column(SLBigInteger(), primary_key=True)
client_id = Column(SLBigInteger(), primary_key=True)
published = Column(Boolean, default=False, nullable=False)
# approved = Column(Boolean, default=False, nullable=False)
parent = relationship('Entity', backref=backref("publishingentity", uselist=False))


Expand Down Expand Up @@ -921,7 +922,7 @@ def __acl__(self):
pass
object_id = None
try:
object_id = self.request.matchdict['perspective_id']
object_id = self.request.matchdict['perspective_object_id']
except:
pass
return acls + acl_by_groups(object_id, client_id, 'perspective')
Expand Down Expand Up @@ -987,7 +988,7 @@ def __acl__(self):
acls = []
object_id = None
try:
object_id = self.request.matchdict['dictionary_perspective_id']
object_id = self.request.matchdict['dictionary_perspective_object_id']
except:
pass
client_id = None
Expand Down Expand Up @@ -1025,7 +1026,7 @@ def __acl__(self):
acls = []
object_id = None
try:
object_id = self.request.matchdict['perspective_id']
object_id = self.request.matchdict['perspective_object_id']
except:
pass
client_id = None
Expand All @@ -1044,7 +1045,7 @@ def __acl__(self):
acls = []
object_id = None
try:
object_id = self.request.matchdict['perspective_id']
object_id = self.request.matchdict['perspective_object_id']
except:
pass
client_id = None
Expand All @@ -1063,7 +1064,7 @@ def __acl__(self):
acls = []
object_id = None
try:
object_id = self.request.matchdict['perspective_id']
object_id = self.request.matchdict['perspective_object_id']
except:
pass
client_id = None
Expand Down Expand Up @@ -1145,7 +1146,7 @@ def __acl__(self):
acls = []
object_id = None
try:
object_id = self.request.matchdict['perspective_id']
object_id = self.request.matchdict['perspective_object_id']
except:
pass
client_id = None
Expand All @@ -1164,7 +1165,7 @@ def __acl__(self):
acls = []
object_id = None
try:
object_id = self.request.matchdict['perspective_id']
object_id = self.request.matchdict['perspective_object_id']
except:
pass
client_id = None
Expand Down
4 changes: 2 additions & 2 deletions lingvodoc/views/v2/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ def blob_upload_get(request):
dictionary_client_id = request.matchdict.get('dictionary_client_id')
dictionary_object_id = request.matchdict.get('dictionary_object_id')
perspective_client_id = request.matchdict.get('perspective_client_id')
perspective_id = request.matchdict.get('perspective_id')
perspective_object_id = request.matchdict.get('perspective_object_id')

variables = {'client_id': client_id, 'user': user, 'dictionary_client_id': dictionary_client_id,
'dictionary_object_id': dictionary_object_id, 'perspective_client_id': perspective_client_id,
'perspective_id': perspective_id}
'perspective_object_id': perspective_object_id}

return render_to_response('templates/user_upload.pt', variables, request=request)
2 changes: 1 addition & 1 deletion lingvodoc/views/v2/convert/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def convert_dictionary_check(request): # TODO: test
dictionary_client_id=perspective.parent_client_id,
dictionary_object_id=perspective.parent_object_id,
perspective_client_id=perspective.client_id,
perspective_id=perspective.object_id)
perspective_object_id=perspective.object_id)
subreq = Request.blank(path)
subreq.method = 'GET'
subreq.headers = request.headers
Expand Down
Loading

0 comments on commit 1087037

Please sign in to comment.