Model and submit API updates

NOTE: Not ready for merge because tests are incomplete, but I need to stop for the day, so sharing progress.

Changes to model and submit API that make submitting straightforward. Submission is the most common action, so I rewrote the model such that submitting doesn't need to change User or Assignment records.

Per Stephen's suggestions, all API code is back in api.py and the NDB interface is an object. Comments are welcome.

Testing is incomplete, but I won't get to finish it until tomorrow. 
As far as I know, the parent is only used for synchronization and is not
part of the record. I think it can't be None, based on the tutorial
examples. (There's no reason why we wouldn't have a user at this point
anyway, I think.)

3rd paragraph of
https://developers.google.com/appengine/docs/python/gettingstartedpython27/usingdatastore




On Tue, Jul 29, 2014 at 7:19 AM, Stephen Martinis <notifications@github.com>
wrote:

> In server/app/api.py:
>
> > @@ -124,37 +126,63 @@ def get_model(cls):
> >          return models.Assignment
> >
> >
> > +class SubmitNDBImplementation:
> > +    """Implementation of DB calls required by submission using Google NDB"""
> > +
> > +    def lookup_assignments_by_name(self, name):
> > +        """Look up all assignments of a given name."""
> > +        by_name = models.Assignment.name == name
> > +        return list(models.Assignment.query().filter(by_name))
> > +
> > +    def create_submission(self, user, assignment, messages):
> > +        """Create submission using user as parent to ensure ordering."""
> > +        user_key = Key.from_path('User', user or 'no user')
>
> I think it might be a bit problematic to store the Submission with it's
> submitter set to some bogus user. Why don't we just set the user to None?
>
> Although there wouldn't be a parent key then... is that why we have a
> bogus user?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/Cal-CS-61A-Staff/ok/pull/38/files#r15506426>.
>