[enh] Add the repository from where the app is defined in app_list

The *repository* term is quite new and will replace *app list* in a near
future. It is - for the moment - only shown and used in the Web admin.
This also removes the unused app['manifest']['orphan'] key since it
duplicates the repository absence.
This commit is contained in:
Jérôme Lebleu 2016-03-01 16:05:10 +01:00
parent 54f2b23bd0
commit f860c5dfd2

View file

@ -142,21 +142,25 @@ def app_list(offset=None, limit=None, filter=None, raw=False):
if limit: limit = int(limit) if limit: limit = int(limit)
else: limit = 1000 else: limit = 1000
applists = os.listdir(repo_path)
app_dict = {} app_dict = {}
if raw: if raw:
list_dict = {} list_dict = {}
else: else:
list_dict=[] list_dict = []
if not applists: try:
app_fetchlist() applists = app_listlists()['lists']
applists = os.listdir(repo_path) applists[0]
except IOError, IndexError:
app_fetchlists()
applists = app_listlists()['lists']
for applist in applists: for applist in applists:
if '.json' in applist: with open(os.path.join(repo_path, applist + '.json')) as json_list:
with open(repo_path +'/'+ applist) as json_list: for app, info in json.loads(str(json_list.read())).items():
app_dict.update(json.loads(str(json_list.read()))) if app not in app_dict:
info['repository'] = applist
app_dict[app] = info
for app in os.listdir(apps_setting_path): for app in os.listdir(apps_setting_path):
if app not in app_dict: if app not in app_dict:
@ -168,7 +172,7 @@ def app_list(offset=None, limit=None, filter=None, raw=False):
continue continue
with open( apps_setting_path + app +'/manifest.json') as json_manifest: with open( apps_setting_path + app +'/manifest.json') as json_manifest:
app_dict[app] = {"manifest":json.loads(str(json_manifest.read()))} app_dict[app] = {"manifest":json.loads(str(json_manifest.read()))}
app_dict[app]['manifest']['orphan']=True app_dict[app]['repository'] = None
if len(app_dict) > (0 + offset) and limit > 0: if len(app_dict) > (0 + offset) and limit > 0:
sorted_app_dict = {} sorted_app_dict = {}