mirror of
https://github.com/simon987/nyaa.git
synced 2025-12-16 00:09:05 +00:00
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:
@@ -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! :/ '''
|
||||
|
||||
Reference in New Issue
Block a user