示例#1
0
 def professor_toggle_dislike(self, request):
     user = endpoints.get_current_user()
     professor = Professor.get_professor(request.value)
     if not(user and professor):
         return API.BooleanMessage(value=False)
     professor.toggle_dislike(user.email())
     return API.BooleanMessage(value=True)
示例#2
0
 def professor_rate(self, request):
     user = endpoints.get_current_user()
     professor = Professor.get_professor(request.id)
     if not(user and professor):
         return API.BooleanMessage(value=False)
     professor.rate(user.email(), request.personality, request.teaching_skill,
                    request.research_skill, request.knowledge_level)
     return API.BooleanMessage(value=True)
示例#3
0
 def professor_get_rating(self, request):
     user = endpoints.get_current_user()
     professor = Professor.get_professor(request.value)
     if not (professor and user):
         return RatingResponse()
     rating = professor.get_rating(user.email())
     if not rating:
         return RatingResponse()
     return RatingResponse(rating=createRatingMessage(rating))
示例#4
0
 def professor_get_articles(self, request):
     professor = Professor.get_professor(request.value)
     if not professor:
         return article_api.MultiArticleResponse(articles=[])
     articles = [article_api.createArticleMessage(article) for article in professor.get_articles()]
     return article_api.MultiArticleResponse(articles=articles)
示例#5
0
 def professor_get_comments(self, request):
     professor = Professor.get_professor(request.value)
     if not professor:
         return comment_api.MultiCommentResponse(comments=[])
     comments = [comment_api.createCommentMessage(comment) for comment in professor.get_comments()]
     return comment_api.MultiCommentResponse(comments=comments)
示例#6
0
 def professor_get_all(self, request):
     professors = [createProfessorMessage(professor) for professor in Professor.get_all_professors()]
     return MultiProfessorResponse(professors=professors)
示例#7
0
 def professor_get(self, request):
     professor = Professor.get_professor(request.value)
     if not professor:
         return ProfessorResponse()
     return ProfessorResponse(professor=createProfessorMessage(professor))
示例#8
0
 def professor_write_article(self, request):
     user = endpoints.get_current_user()
     professor = Professor.get_professor(request.id)
     if not(user and professor):
         return API.IntegerMessage(value=-1)
     return API.IntegerMessage(value=professor.write_article(user.email(), request.title, request.content))
示例#9
0
 def post(self):
     upload = self.get_uploads('professor_info')[0]
     blob_reader = blobstore.BlobReader(upload.key())
     prof_info = json.loads(blob_reader.read())
     blobstore.delete(upload.key())
     for prof in prof_info:
         if len(Professor.query(Professor.name==prof['name'], Professor.title==prof['title']).fetch()) == 0:
             professor = Professor(name=prof['name'], title=prof['title'], special_title=prof['special title'],
                                   image=prof['image'], introduction=prof['introduction'], research_areas=prof['research areas'],
                                   research_interests=prof['research interests'], research_groups=prof['research groups'],
                                   office=prof['office'], phone=prof['phone'], email=prof['email'],
                                   personal_website=prof['personal website'])
         else:
             professor = Professor.query(Professor.name==prof['name'], Professor.title==prof['title']).fetch()[0]
             professor.special_title = prof['special title']
             professor.image = prof['image']
             professor.introduction = prof['introduction']
             professor.research_areas = prof['research areas']
             professor.research_interests = prof['research interests']
             professor.research_groups = prof['research groups']
             professor.office = prof['office']
             professor.phone=prof['phone']
             professor.email=prof['email']
             professor.personal_website=prof['personal website']
         professor.put()
     self.redirect('/admin', True)
示例#10
0
 def get(self):
     parameters = dict()
     parameters['professors'] = Professor.get_all_professors()
     parameters['upload_url'] = blobstore.create_upload_url('/admin/upload')
     self.response.write(renderTemplate(template, parameters))