Last active
August 29, 2015 14:06
-
-
Save fisherds/a6c1e86f948fcd034ae4 to your computer and use it in GitHub Desktop.
Post handler to insert an Assignment for our GradeRecorder web app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class InsertAssignmentAction(webapp2.RequestHandler): | |
| def post(self): | |
| user = users.get_current_user() | |
| urlsafe_entity_key = self.request.get('assignment_entity_key') | |
| if len(urlsafe_entity_key) > 0: | |
| # Edit | |
| assignment_key = ndb.Key(urlsafe=urlsafe_entity_key) | |
| assignment = assignment_key.get() | |
| else: | |
| # Add | |
| assignment = Assignment(parent=utils.get_parent_key(user)) | |
| assignment.name = self.request.get('assignment_name') | |
| assignment.put() | |
| self.redirect("/?active_assignment=" + assignment.key.urlsafe()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment