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. 
Parent isn't stored, AFAIK — see above.


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')
>
> Also, why are we storing submitter separate from the parent? Doesn't the
> parent already have this information? Or could they be different in certain
> cases.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/Cal-CS-61A-Staff/ok/pull/38/files#r15506446>.
>