0.5.14 pdf articles export

This commit is contained in:
SDE
2024-07-17 01:50:03 +03:00
parent f11a3f0463
commit 845518b3ef
13 changed files with 310 additions and 40 deletions

View File

@@ -1,6 +1,6 @@
from .models import *
def get_options_by_opt_types(opt_types, only_vals=False):
def get_options_by_opt_types(opt_types, only_vals=False, w_prefix=False):
if type(opt_types) == str:
kwargs = {'opt_type': opt_types}
elif type(opt_types) == dict:
@@ -10,8 +10,11 @@ def get_options_by_opt_types(opt_types, only_vals=False):
opts = Option.objects.filter(**kwargs)
if opts and only_vals:
opts = opts.values('opt_type', 'value')
opts = {item['opt_type']: item['value'] for item in opts}
opts = opts.values('opt_type', 'value', 'prefix')
if w_prefix:
opts = {item['opt_type']: f"{item['prefix']}{item['value']}" for item in opts}
else:
opts = {item['opt_type']: item['value'] for item in opts}
return opts
def get_first_option_value_by_opt_type(opt_type):