Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/xwy27/Designer
Browse files Browse the repository at this point in the history
  • Loading branch information
gtbl2012 committed Oct 17, 2018
2 parents 24872c6 + 3dc6482 commit 1c8c590
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 24 deletions.
23 changes: 23 additions & 0 deletions designSite/design/migrations/0030_auto_20181017_1335.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
36 changes: 19 additions & 17 deletions designSite/design/tools/pre_load_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '')
Expand Down Expand Up @@ -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()
15 changes: 15 additions & 0 deletions designSite/design/views/design_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion designSite/opt_sim_module/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions designSite/search/views/search_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions designSite/static/js/design.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
}
});
});

Expand Down

0 comments on commit 1c8c590

Please sign in to comment.