diff --git a/designSite/design/migrations/0030_auto_20181017_1335.py b/designSite/design/migrations/0030_auto_20181017_1335.py new file mode 100644 index 0000000..74ba576 --- /dev/null +++ b/designSite/design/migrations/0030_auto_20181017_1335.py @@ -0,0 +1,23 @@ +# Generated by Django 2.1.1 on 2018-10-17 13:35 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('design', '0029_auto_20181017_0130'), + ] + + operations = [ + migrations.AlterField( + model_name='works', + name='DefaultImg', + field=models.URLField(default='static/img/Team_img/none.jpg'), + ), + migrations.AlterField( + model_name='works', + name='logo', + field=models.URLField(default='static/img/Team_img/none.jpg'), + ), + ] diff --git a/designSite/design/tools/pre_load_data.py b/designSite/design/tools/pre_load_data.py index 414ca8e..9b48349 100644 --- a/designSite/design/tools/pre_load_data.py +++ b/designSite/design/tools/pre_load_data.py @@ -1129,13 +1129,15 @@ def load_chassis(path): def final(): + print("Finalizing...") for i in Works.objects.filter(Year__lte = 2008): i.delete() - for work in Works.objects.filter(Circuit = None, Year__lte = 2016): - parts = work.Use_parts.split(';') - if len(parts) == 0: + + for work in Works.objects.filter(Circuit = None): + if len(work.Use_parts) == 0: # No parts info continue + parts = work.Use_parts.split(';') circuit = Circuit.objects.create( Name = work.Teamname + str(work.TeamID), Description = '') @@ -1240,18 +1242,18 @@ def load_2017_works(works_floder_path): def pre_load_data(currentpath, Imgpath): - load_parts(os.path.join(currentpath, 'parts')) - load_chassis(os.path.join(currentpath, 'chassis')) - # load_partsInteration(os.path.join(currentpath, 'partsinteract')) - load_partsParameter(os.path.join(currentpath, 'partsParameter')) - load_works(os.path.join(currentpath, 'works')) - load_2017_works(os.path.join(currentpath, 'works')) - load_Trelation(os.path.join(currentpath, 'TeamRelation')) - load_Teamkeyword(os.path.join(currentpath, 'TeamKeyword')) - load_papers(os.path.join(currentpath, 'papers')) - load_circuits(os.path.join(currentpath, 'works/circuits'), delete=True) - load_2017_circuits(os.path.join(currentpath, 'works/circuits/2017.xlsx')) - load_circuits(os.path.join(currentpath, 'papers/circuits'), is_work = False) - # #load_circuits(os.path.join(currentpath, 'works/circuits2')) - load_additional(os.path.join(currentpath, 'additional')) + # load_parts(os.path.join(currentpath, 'parts')) + # load_chassis(os.path.join(currentpath, 'chassis')) + # # load_partsInteration(os.path.join(currentpath, 'partsinteract')) + # load_partsParameter(os.path.join(currentpath, 'partsParameter')) + # load_works(os.path.join(currentpath, 'works')) + # load_2017_works(os.path.join(currentpath, 'works')) + # load_Trelation(os.path.join(currentpath, 'TeamRelation')) + # load_Teamkeyword(os.path.join(currentpath, 'TeamKeyword')) + # load_papers(os.path.join(currentpath, 'papers')) + # load_circuits(os.path.join(currentpath, 'works/circuits'), delete=True) + # load_2017_circuits(os.path.join(currentpath, 'works/circuits/2017.xlsx')) + # load_circuits(os.path.join(currentpath, 'papers/circuits'), is_work = False) + # # #load_circuits(os.path.join(currentpath, 'works/circuits2')) + # load_additional(os.path.join(currentpath, 'additional')) final() \ No newline at end of file diff --git a/designSite/design/views/design_views.py b/designSite/design/views/design_views.py index d661fd7..1a8fbfb 100644 --- a/designSite/design/views/design_views.py +++ b/designSite/design/views/design_views.py @@ -826,14 +826,29 @@ def circuit(request): for i in data['combines'][x]: cd.Sons.add(cids[i]) cd.save() + # now update authority if necessary. for example, `A` save a circuit shared by `B`. + logger.debug('should I update authority?') + if not new and request.user != old_circuit.Author: + logger.debug('save new version and circuit not own by "me"') + auth_query = Authorities.objects.filter(Circuit__Name=name) + logger.debug('revalent auth query %s', auth_query) + if auth_query: + Authorities.objects.create( + User=request.user, + Circuit=circuit, + Authority='write' + ) + logger.debug('insert new write authority') return JsonResponse({ 'status': 1, 'circuit_id': circuit.id}) + except: traceback.print_exc() return JsonResponse({ 'status': 0 }) + else: return JsonResponse({ 'status': 0}) diff --git a/designSite/opt_sim_module/optimize.py b/designSite/opt_sim_module/optimize.py index 0e67f61..5d59c42 100644 --- a/designSite/opt_sim_module/optimize.py +++ b/designSite/opt_sim_module/optimize.py @@ -4,7 +4,7 @@ import math from opt_sim_module.solve import * -def optimization(data, target, k, evol_t,ith_protein): +def optimization(data, target, k, evol_t, ith_protein): class Chrom: chrom = [] fitness = 0.0 diff --git a/designSite/search/views/search_views.py b/designSite/search/views/search_views.py index c92525a..49bddc4 100644 --- a/designSite/search/views/search_views.py +++ b/designSite/search/views/search_views.py @@ -57,10 +57,15 @@ def update(w_dict, key, w): logging.info(keys) w_dict = {} if search_type == 'project': - # try: - nn_search_result = recommend_team(keys[0]) - # except: - # logging.info("Unable to load nn search module.") + if search.nn_search_flag >= 0: + #TODO: I change here. + try: + nn_search_result = recommend_team(keys[0]) + search.nn_search_flag = 1 # nn_search module is initialized successfully + logging.info("Search module activated!") + except: + logging.info("Unable to load nn search module.") + search.nn_search_flag = -1 ## nn_search module failed for key in keys: if key.isdigit(): # May be year q_on_Year = Works.objects.filter(Year__exact=int(key)) @@ -188,6 +193,7 @@ def update(w_dict, key, w): }) # logging.info(context) return render(request, 'search_result.html', context) +search.nn_search_flag = 0 @login_required diff --git a/designSite/static/js/design.js b/designSite/static/js/design.js index c17997c..d3f056b 100644 --- a/designSite/static/js/design.js +++ b/designSite/static/js/design.js @@ -816,8 +816,14 @@ $('#save-circuit, #save-as-new-circuit').on('click', () => { }, 3000); // Redirect to the new design - if (v.status === 1) - window.location.replace(`/design/${v.circuit_id}`); + if (v.status === 1) { + let url = window.location.href.split('/'); + if (url.indexOf('share') !== -1) { + window.location.replace(`/design/share/${v.circuit_id}`); + } else { + window.location.replace(`/design/${v.circuit_id}`); + } + } }); });