Move torrent edit and upload into 'torrents' blueprint

Move supporting functions and variables into other files
* nyaa.views.torrents:
  - _create_upload_category_choices
* nyaa.backend:
  - get_category_id_map
This commit is contained in:
Kfir Hadas
2017-07-24 23:10:36 +03:00
parent 9acdd14e81
commit 9fef343c1b
6 changed files with 127 additions and 127 deletions

View File

@@ -12,6 +12,19 @@ from orderedset import OrderedSet
from ipaddress import ip_address
@utils.cached_function
def get_category_id_map():
''' Reads database for categories and turns them into a dict with
ids as keys and name list as the value, ala
{'1_0': ['Anime'], '1_2': ['Anime', 'English-translated'], ...} '''
cat_id_map = {}
for main_cat in models.MainCategory.query:
cat_id_map[main_cat.id_as_string] = [main_cat.name]
for sub_cat in main_cat.sub_categories:
cat_id_map[sub_cat.id_as_string] = [main_cat.name, sub_cat.name]
return cat_id_map
def _replace_utf8_values(dict_or_list):
''' Will replace 'property' with 'property.utf-8' and remove latter if it exists.
Thanks, bitcomet! :/ '''