workout/gym/mixins.py

16 lines
481 B
Python

class SessionResetMixin:
def dispatch(self, request, *args, **kwargs):
if "session_pk" in request.session:
del request.session["session_pk"]
return super().dispatch(request, *args, **kwargs)
class QuickActionsMixin:
def get_quick_actions(self):
return []
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["quick_actions"] = self.get_quick_actions()
return context