def test_reviewers_cant_make_evaluations(self): u = User() u.username = '******' u.set_password('goscience') u.save() c = Client() logged_in = c.login(username='******', password='******') self.assertTrue(logged_in) # attempt to edit evaluation r = Reviewer() r.user = u r.name = 'Foo' r.affiliation = 'COS' r.email = '*****@*****.**' r.bio = 'Interested in opening up the sciences.' r.research = 'Metascience' r.website = 'http://cos.io' r.osfreviews = 0 r.save() ev = Evaluation() ev.status = 'Pending' ev.progress = 'Received' ev.premise = 5 ev.research = 6 ev.style = 4 ev.comment = 'This is a comment.' ev.reviewer = r ev.submission = Submission.objects.first() ev.save()
def setUp(self): u = User() u.username = '******' u.save() r = Reviewer() r.user = u r.name = 'Luke' r.affiliation = 'COS' r.email = '*****@*****.**' r.bio = 'I love to have fun.' r.research = 'Fun Facts' r.website = 'http://lukemarsh.com' r.osfreviews = 0 r.save() s = Submission() s.conference = 'FooCon' s.title = 'Effects of Foo on Bar' s.reviewdeadline = datetime.date(2016, 12, 25).isoformat() s.authorname = 'Foo Bar' s.authoremail = '*****@*****.**' s.status = 'Awaiting review' s.link = 'http://foobar.org' s.attachment = '/foo/bar.pdf' s.save() s.reviewer.add(r) s.save() u2 = User() u2.username = '******' u2.save() ed = Editor() ed.user = u2 ed.name = 'Tom Heatwole' ed.email = '*****@*****.**' ed.save() s.editor = ed s.save() ev = Evaluation() ev.status = 'Pending' ev.progress = 'Received' ev.premise = 5 ev.research = 6 ev.style = 4 ev.comment = 'This is a comment.' ev.reviewer = r ev.submission = s ev.save()
def post(self): quarter = SettingModel.quarter() year = SettingModel.year() user = users.get_current_user() evaluator = StudentModel.get_student_by_email(quarter, year, user.email()) partners = PartnershipModel.get_active_partner_history_for_student( evaluator, quarter, year) eval_key, num = split_last(self.request.get('evaluatee')) eval_assign = int(num) current_partner = ndb.Key(urlsafe=eval_key).get() # Log when eval is submitted #current date for timestamp cur_date = datetime.datetime.now().strftime("%m/%d/%Y %H:%M:%S") #get current log, creating one if it does not exist current_log = LogModel.get_log_by_student(evaluator, quarter, year).get() if current_log == None: current_log = Log() current_log.owner = evaluator.key current_log.quarter = quarter current_log.year = year #log the submission of the eval current_log.log.append(cur_date + " Submitted eval for: " + current_partner.ucinetid + " assgt. " + str(eval_assign)) #save to log current_log.put() evaluations = EvalModel.get_existing_eval_by_assign( evaluator, current_partner, eval_assign) for eval in evaluations: eval.active = False eval.put() evaluation = Evaluation(evaluator=evaluator.key, evaluatee=current_partner.key) evaluation.assignment_number = eval_assign evaluation.year = evaluator.year evaluation.quarter = evaluator.quarter evaluation.active = True for i in range(1, 11): evaluation.responses.append(self.request.get('q' + str(i))) evaluation.put() message = 'Evaluation for ' + str(current_partner.last_name) + ', ' message += str( current_partner.first_name ) + ' confirmed: Please refresh the page and confirm the evaluation was submitted.' self.redirect('/partner?message=' + message)
def create_evaluations_for(match): """ :param match: Match :return list: list of Evaluation for each user of match """ evaluations = [] for i, user in enumerate(match.users): if i == 0: mate = match.users[1] else: mate = match.users[0] evaluation = Evaluation(match, user, mate) evaluations.append(evaluation) return evaluations
def submit_evaluation(request): if request.method == 'POST': eval1 = EvaluationForm(request.POST) if eval1.is_valid(): x = Evaluation() x.participation = eval1.cleaned_data["participation"] x.communication = eval1.cleaned_data["communication"] x.presentation = eval1.cleaned_data["presentation"] x.techskill = eval1.cleaned_data["techskill"] x.save() return HttpResponseRedirect("/valid_submission") else: eval1 = EvaluationForm() return render(request, "loggedin.html", {"eval1": eval1})
def evaluation(request): if request.method == 'POST': form = EvaluationForm(request.POST) if form.is_valid(): ev = Evaluation() ev.author = form.cleaned_data["author"] = request.user ev.evaluee = form.cleaned_data["evaluee"] ev.participation = form.cleaned_data["participation"] ev.communication = form.cleaned_data["communication"] ev.presentation = form.cleaned_data["presentation"] ev.techskill = form.cleaned_data["techskill"] ev.save() return HttpResponseRedirect("/confirmation") elif request.method == 'GET': form = EvaluationForm() else: return HttpResponseRedirect("/404/") return render(request, 'evaluation.html', { "form": form, "teams": Team.objects.all })
def create_Evaluation(): try: data = request.get_json() #nameEntity=data['nameEntity'] #addressEntity=data['addressEntity'] idEntity = data['idEntity'] idPlan = data['idPlan'] idUser = data['idUser'] initialDate = date.today() #entity = Entity(name=nameEntity, address=addressEntity) #entity.save() #entity_evaluation= Entity.get_by_name(nameEntity) #idEntity=entity_evaluation.idEntity #date.today().strftime("%d/%m/%Y") evaluation = Evaluation(idEntity=idEntity, idPlan=idPlan, idUser=idUser, idStatus=1, initialDate=initialDate, idPhase=4) evaluation.save() lastEvaluation = Evaluation.get_last_registration() criticalVariable_list = [] criterion_list = [] criterionList = db.session.query(Criterion_X_CriticalVariable,Criterion,CriticalVariable).\ join(Criterion_X_CriticalVariable.criterion,Criterion_X_CriticalVariable.criticalVariable).filter(Criterion.idPlan==idPlan).all() for criterion in criterionList: modifyWeight = EvaluationModifiedWeight( idCriterion_X_CriticalVariable=criterion[0]. idCriterion_X_CriticalVariable, idEvaluation=lastEvaluation.idEvaluation, idModifiedWeight=criterion[0].idWeight) modifyWeight.save() if (criterion[2] not in criticalVariable_list): criticalVariable_list.append(criterion[2]) if (criterion[1] not in criterion_list): criterion_list.append(criterion[1]) indicatorList = db.session.query(Indicator,CriticalVariable).\ join(Indicator.criticalVariable).order_by(Indicator.idIndicator.asc()).all() for indicator in indicatorList: if (indicator[1] in criticalVariable_list): evaluation_indicator = Evaluation_X_Indicator( idIndicator=indicator[0].idIndicator, idEvaluation=lastEvaluation.idEvaluation) evaluation_indicator.save() questionList = db.session.query(Question,CriticalVariable).\ join(Question.criticalVariable).order_by(Question.idQuestion.asc()).all() for question in questionList: if (question[1] in criticalVariable_list): evaluation_question = Evaluation_X_Question( idQuestion=question[0].idQuestion, idEvaluation=lastEvaluation.idEvaluation, answer=-1) evaluation_question.save() for crit in criterion_list: objective_row = ObjectiveStrategic( idCriterion=crit.idCriterion, idEvaluation=lastEvaluation.idEvaluation, description="Sin Objetivo") objective_row.save() return jsonify(result={"status": 200}) except Exception as e: db.session.rollback() return jsonify(result={"error": 400})