diff --git a/django_lostplaces/docs/developer.md b/django_lostplaces/docs/developer.md new file mode 100644 index 0000000..4ca7725 --- /dev/null +++ b/django_lostplaces/docs/developer.md @@ -0,0 +1,75 @@ +# django lostplaces documentation for developer + +Greetings, +this documentation is for anyone who wants to work with this projects codebase or is just curious about our project. + + +## Models +The models contain an custom user profile, some abstract base models and the models holding the actual data for this project + + +### Explorer user profile +The class `lostplaces.models.Explorer` is our custom user profile. It has an ForeignKey pointing at django's default user model instead of providing an entire custom user model. That way this django app does not conflict with any other app that has to bring it's own user model. + +You can access the explorer profile by accessing the 'explorer' attribute of any user instance +```python +user.explorere +``` + +Currently the explorer profile is used by the abstract model 'Submittable' and thus referenced by 'Place' and 'PlaceImage'. The explorer profile therefore has two attributes +```python +user.explorer.places +user.explorere.placeimages +``` +`places` +A list containing all (lost) places the user has submitted +`placeimages` +A list containing all images relating a place that a user has submitted + + +### Taggable +The abstract model Taggable represents an model that is taggable. It depends on the django app [taggit](https://github.com/jazzband/django-taggit). It only consists of one field: +`tag` +TaggableManager, allows the sub class to be tagged, blank=True allows the admin form to be submitted without any tags + + +### Mapable +The abstract model Mapable represents an model that can be displayed on a map. It consists of tree members +`name` +Name of the object, displayed on the map, max length 50 characeter +`latitude` +Latitude of the referenced location, -90 <= value <= 90 +`longitude` +Longitude of the referenced location -180 <= value <= 180 +A mapable model has to provide its own get_aboslute_url, in order to provide a link when clicked. + + +### Submittable +The abstract model Submittable represents an model that can be submitted by an user. It knows who submitted something and when: +`submitted_by` +Referencing the explorer profile, see [Explorer](##explorer-user-profile). If the explorer profile is deleted, this instance is kept (on_delete=models.SET_NULL). The related_name is set to the class name, lower case appending an s (%(class)s) +`submitted_when` +When the object was submitted, automaticly set by django (auto_now_add=True) + + +### Voucher +A voucher code is needed to sign up using lostplaces sign up form. The model contains +`code` +The voucher code, max length 30 character +`created_when` +When the voucher was created automaticly set by django (auto_now_add=True) +`expires_when` +Till what date the voucher remains valid + + +### Place +The place model is the heart of this project. It stores all information about a place needed. +`location` +Human readable location description (town, village, street), max length 50 character +`description` +Describing the place in detail +The place model uses these abstract super classes +- Submittable, see [Submittable](##submittable) for additional fields +- Taggable, see [Taggable](##taggable) for additional fields +- Mapable, see [Mapable](##mapable) for additional fields +The average_latlon function takes a list of places and returns the center point of all these places