* update font-awesome to 5.12.1 * prefetch members to considerably lower number of SQL queries for team list view * add facilities app with facility feeedback functionality, working on #383 * Add GeoDjango (django.contrib.gis) and switch to PostGIS db backend. Add location field for Facility model. Add django-leaflet to requirements. * better migration names * tweaking travis config, we use py3.7 now, and add postgis * Add qr code support for facilities (visible in the admin). Make facitilies browsable without logging in. Feedback can be submitted without logging in, given the facility UUID, which is not revealed to unauthenticated users. * show quickfeedback icons when creating and when reading feedback * only show anon option if user is logged in * django-reversion somehow went missing from requirements
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
from camps.mixins import CampViewMixin
|
|
from django.shortcuts import get_object_or_404
|
|
|
|
from .models import Facility, FacilityType
|
|
|
|
|
|
class FacilityTypeViewMixin(CampViewMixin):
|
|
"""
|
|
A mixin to get the FacilityType object based on facility_type_slug in url kwargs
|
|
"""
|
|
|
|
def setup(self, *args, **kwargs):
|
|
super().setup(*args, **kwargs)
|
|
self.facility_type = get_object_or_404(
|
|
FacilityType,
|
|
responsible_team__camp=self.camp,
|
|
slug=self.kwargs["facility_type_slug"],
|
|
)
|
|
|
|
def get_context_data(self, *args, **kwargs):
|
|
context = super().get_context_data(*args, **kwargs)
|
|
context["facilitytype"] = self.facility_type
|
|
return context
|
|
|
|
|
|
class FacilityViewMixin(FacilityTypeViewMixin):
|
|
"""
|
|
A mixin to get the Facility object based on facility_uuid in url kwargs
|
|
"""
|
|
|
|
def setup(self, *args, **kwargs):
|
|
super().setup(*args, **kwargs)
|
|
self.facility = get_object_or_404(
|
|
Facility,
|
|
facility_type=self.facility_type,
|
|
uuid=self.kwargs["facility_uuid"],
|
|
)
|
|
|
|
def get_context_data(self, *args, **kwargs):
|
|
context = super().get_context_data(*args, **kwargs)
|
|
context["facility"] = self.facility
|
|
return context
|