Core Views¶
-
class
fyt.db.views.DatabaseLandingPage(**kwargs)[source]¶ Landing page of a particular trips_year in the database
TODO: should this display the Trips index?
-
class
fyt.db.views.DatabaseUpdateView(**kwargs)[source]¶ Base view for updating an object in the database.
If ‘delete_button’ is True, a link to the delete view for this object will be added to the form’s button holder.
-
class
fyt.db.views.RedirectToCurrentDatabase(*args, **kwargs)[source]¶ Redirect to the trips database for the current year.
This view is the target of database urls.
-
class
fyt.db.views.TripsYearMixin[source]¶ Mixin for
trips_year.Filters objects by the
trips_yearnamed group in the url.Plugs into ModelViews. The url is a database url of the form /something/{{trips_year}}/something. The ListView will only display objects for the specified trips_year.
-
dispatch(request, *args, **kwargs)[source]¶ Make sure the request is for a valid trips year.
Requesting a
trips_yearthat don’t exist in the db will cause problems. Block ‘em here.
-
form_valid(form)[source]¶ Called for valid forms - specifically Create and Update
This deals with a corner case of form validation. Uniqueness constraints don’t get caught til the object is saved and raises an IntegrityError.
We catch this error and pass it to form_invalid.
TODO: parse and prettify the error message. Can we look at object._meta.unique_together? Can we make sure it is a uniqueness error?
-