Skip to content

Commit

Permalink
Merge pull request #1264 from myrix/heavy_refactor
Browse files Browse the repository at this point in the history
'Save dictionary' with sounds option #282
  • Loading branch information
myrix authored Sep 14, 2020
2 parents 5aa570b + 5ebf4e0 commit bcdde40
Show file tree
Hide file tree
Showing 12 changed files with 739 additions and 143 deletions.
13 changes: 10 additions & 3 deletions development.ini
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ formatter = generic

[handler_filelog]
class = handlers.RotatingFileHandler
args = ('%(here)s/pyramid.log', 'a', 16777216, 1)
args = ('%(here)s/pyramid.log', 'a', 16777216, 8)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(pathname)s:%(lineno)d: %(message)s

[app:accounts]
use = egg:lingvodoc
Expand All @@ -97,6 +97,13 @@ static_route = objects/
#auth_version = 2.0
#tenant_name = admin

[backend:storage.temporary]
host = minio.at.ispras.ru
access_key = ld_development_access_key
secret_key = ld_development_secret_key
bucket = lingvodoc-temp-files
prefix = dev/

# Info of the SMTP server account used to send emails, e.g. emails of user signup approval.
[smtp]
host = mail.ispras.ru
Expand Down Expand Up @@ -137,7 +144,7 @@ callable = lingvodoc

# Caching.
[cache:dogpile]
expiration_time = 36000
expiration_time = 3600000
backend = dogpile.cache.redis
;backend = dogpile.cache.memcached

Expand Down
2 changes: 2 additions & 0 deletions docker/docker-compose-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ services:
- ./frontend/dist:/dist
- ./nginx:/etc/nginx/conf.d
- ./sock:/sock
- /tmp:/tmp
depends_on:
- pg
- api
Expand Down Expand Up @@ -75,6 +76,7 @@ services:
- ./sock:/sock
- /api/build/
- ../:/api
- /tmp:/tmp

env_file:
- ./locale_env.sh
Expand Down
2 changes: 2 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
- ./frontend/dist:/dist
- ./nginx:/etc/nginx/conf.d
- ./sock:/sock
- /tmp:/tmp
depends_on:
- pg
- api
Expand All @@ -46,6 +47,7 @@ services:
- ./sock:/sock
- /api/build/
- ../:/api
- /tmp:/tmp

env_file:
- ./locale_env.sh
Expand Down
7 changes: 7 additions & 0 deletions docker/docker-proxy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ path = /tmp/
prefix = http://localhost/
static_route = objects/

[backend:storage.temporary]
host = minio.at.ispras.ru
access_key = ld_development_access_key
secret_key = ld_development_secret_key
bucket = lingvodoc-temp-files
prefix = dev/

[cache:dogpile]
expiration_time = 3600000
backend = dogpile.cache.redis
Expand Down
7 changes: 7 additions & 0 deletions docker/docker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ path = /tmp/
prefix = http://localhost/
static_route = objects/

[backend:storage.temporary]
host = minio.at.ispras.ru
access_key = ld_development_access_key
secret_key = ld_development_secret_key
bucket = lingvodoc-temp-files
prefix = dev/

[cache:dogpile]
expiration_time = 3600000
backend = dogpile.cache.redis
Expand Down
2 changes: 1 addition & 1 deletion docker/nginx/lingvodoc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ server {


location /objects/ {
root /tmp;
alias /tmp/;
}

location ~* \.(?:manifest|appcache|html?|xml|json)$ {
Expand Down
20 changes: 17 additions & 3 deletions lingvodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,9 +1021,23 @@ def main(global_config, **settings):

# TODO: DANGER

settings['storage'] = dict(parser.items(
'backend:storage' if parser.has_section('backend:storage') else
'storage'))
storage_dict = (

dict(parser.items(
'backend:storage' if parser.has_section('backend:storage') else
'storage')))

if parser.has_section('backend:storage.temporary'):

storage_dict['temporary'] = (
dict(parser.items('backend:storage.temporary')))

elif parser.has_section('storage.temporary'):

storage_dict['temporary'] = (
dict(parser.items('storage.temporary')))

settings['storage'] = storage_dict

if parser.has_section('app:desktop'):
storage = dict()
Expand Down
7 changes: 7 additions & 0 deletions lingvodoc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,13 @@ def data_type(self):

return translation

@property
def data_type_translation_gist_id(self):

return (
self.data_type_translation_gist_client_id,
self.data_type_translation_gist_object_id)


class Field(CompositeIdMixin,
Base,
Expand Down
16 changes: 12 additions & 4 deletions lingvodoc/schema/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -7459,6 +7459,7 @@ def save_dictionary(
user_id,
locale_id,
publish,
sound_flag,
synchronous = False,
debug_flag = False):

Expand All @@ -7483,6 +7484,7 @@ def save_dictionary(
my_args["task_key"] = task.key if not synchronous else None
my_args["cache_kwargs"] = request.registry.settings["cache_kwargs"]
my_args["published"] = publish
my_args['sound_flag'] = sound_flag
my_args['__debug_flag__'] = debug_flag

res = (sync_save_dictionary if synchronous else async_save_dictionary.delay)(**my_args)
Expand All @@ -7493,6 +7495,7 @@ class SaveDictionary(graphene.Mutation):
class Arguments:
id = LingvodocID(required=True)
mode = graphene.String(required=True)
sound_flag = graphene.Boolean()
synchronous = graphene.Boolean()
debug_flag = graphene.Boolean()

Expand All @@ -7501,14 +7504,18 @@ class Arguments:
@staticmethod
# @client_id_check()
def mutate(root, info, **args):

request = info.context.request
locale_id = int(request.cookies.get('locale_id') or 2)
dict_id = args['id']
mode = args['mode']
variables = {'auth': authenticated_userid(request)}
client = DBSession.query(Client).filter_by(id=variables['auth']).first()
user = DBSession.query(dbUser).filter_by(id=client.user_id).first()
user_id = user.id
sound_flag = args.get('sound_flag', False)

client_id = authenticated_userid(request)

user_id = (
Client.get_user_by_client_id(client_id).id
if client_id else anonymous_userid(request))

dictionary_obj = DBSession.query(dbDictionary).filter_by(client_id=dict_id[0],
object_id=dict_id[1]).first()
Expand All @@ -7531,6 +7538,7 @@ def mutate(root, info, **args):
user_id,
locale_id,
publish,
sound_flag,
args.get('synchronous', False),
args.get('debug_flag', False))

Expand Down
Loading

0 comments on commit bcdde40

Please sign in to comment.