def create_reviewer(jwt): body = request.get_json() try: name = body.get('name', None) email = body.get('email', None) reviewers = Reviewer.query.filter(Reviewer.name.like(name)).count() print("current", reviewers) if reviewers > 0: raise AuthError({ 'code': 'Bad request', 'description': "This reviewer is already existent" }, 400) reviewer = Reviewer( name=name, email=email) reviewer.insert() return jsonify({ 'success': True, 'reviewers': [reviewer.format()] }) except Exception as e: print("exception error post reviewer", e) print(e) if isinstance(e, AuthError): raise e abort(406)
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 test_reviewers_can_edit_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() e = Evaluation.objects.first() e.comment = 'This is an update to the comment' e.save()
def create(self, validated_data): return Reviewer(**validated_data)