Skip to content

Commit

Permalink
Merge pull request #513 from LukeTapekhin/heavy_refactor
Browse files Browse the repository at this point in the history
delete entity fixed
  • Loading branch information
LukeTapekhin authored Dec 13, 2016
2 parents c33599e + 4c6bb4f commit 2cb454f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
7 changes: 5 additions & 2 deletions lingvodoc/views/v2/perspective/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import logging
import multiprocessing

from sqlalchemy.orm.attributes import flag_modified

from pyramid.httpexceptions import (
HTTPBadRequest,
HTTPConflict,
Expand Down Expand Up @@ -501,10 +503,9 @@ def edit_perspective_meta(request): # tested & in docs
old_meta = perspective.additional_metadata
new_meta = req
old_meta.update(new_meta)
perspective.additional_metadata = old_meta
flag_modified(perspective, 'additional_metadata')
else:
perspective.additional_metadata = req
DBSession.bulk_save_objects([perspective])
request.response.status = HTTPOk.code
return response
request.response.status = HTTPNotFound.code
Expand Down Expand Up @@ -543,6 +544,7 @@ def delete_perspective_meta(request): # tested & in docs
if entry in old_meta:
del old_meta[entry]
perspective.additional_metadata = old_meta
flag_modified(perspective, 'additional_metadata')
request.response.status = HTTPOk.code
return response
request.response.status = HTTPNotFound.code
Expand Down Expand Up @@ -972,6 +974,7 @@ def view_perspective_roles(request): # TODO: test
subject_object_id=object_id,
subject_client_id=client_id).first()
if not group:
print(base.name)
continue
perm = base.name
users = []
Expand Down
32 changes: 21 additions & 11 deletions lingvodoc/views/v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
Client,
Group,
UserBlobs,
Language
Language,
ObjectTOC,
LexicalEntry,
Dictionary,
Entity
)

from sqlalchemy import (
Expand Down Expand Up @@ -52,20 +56,26 @@
import json
import requests
from pyramid.request import Request
from time import time


@view_config(route_name='testing', renderer='json')
def testing(request):
translationgist=TranslationGist(client_id=1, type='Language')
DBSession.add(translationgist)
translationatom=TranslationAtom(client_id=1, parent=translationgist, locale_id=2, content='testing objecttoc')
DBSession.add(translationatom)
lang = Language(client_id=1, translation_gist_client_id=translationgist.client_id,
translation_gist_object_id=translationgist.object_id)
DBSession.add(lang)
DBSession.rollback()
return {}

with_group = 0
without_group = 0
for group in DBSession.query(Group).filter_by(base_group_id=26).all():
DBSession.delete(group)
for persp in DBSession.query(DictionaryPerspective):
group = DBSession.query(Group).filter_by(base_group_id=22, subject_client_id=persp.client_id,
subject_object_id=persp.object_id).first()
if not group:
without_group +=1
new_group = Group(base_group_id=26, subject_client_id=persp.client_id,
subject_object_id=persp.object_id)
for user in group.users:
new_group.users.append(user)
DBSession.add(new_group)
return {"good": with_group, "bad": without_group}

@view_config(route_name='main', renderer='templates/main.pt', request_method='GET')
def main_get(request):
Expand Down

0 comments on commit 2cb454f

Please sign in to comment.