2017-03-18 15:54:23 +00:00
|
|
|
from django.views.generic.detail import SingleObjectMixin
|
|
|
|
from django.contrib import messages
|
|
|
|
from django.shortcuts import redirect
|
|
|
|
from django.urls import reverse
|
|
|
|
|
|
|
|
|
|
|
|
class EnsureWritableCampMixin(SingleObjectMixin):
|
|
|
|
def dispatch(self, request, *args, **kwargs):
|
|
|
|
# do not permit view if camp is in readonly mode
|
|
|
|
if self.camp.read_only:
|
|
|
|
messages.error(request, "No thanks")
|
2018-03-04 14:40:34 +00:00
|
|
|
return redirect(
|
2019-06-16 12:32:24 +00:00
|
|
|
reverse("village_list", kwargs={"camp_slug": self.camp.slug})
|
2018-03-04 14:40:34 +00:00
|
|
|
)
|
2017-03-18 15:54:23 +00:00
|
|
|
|
|
|
|
# alright, continue with the request
|
|
|
|
return super().dispatch(request, *args, **kwargs)
|