diff options
author | Palaparthy Adityachandra | 2020-04-01 09:19:52 +0530 |
---|---|---|
committer | GitHub | 2020-04-01 09:19:52 +0530 |
commit | 193326ebc49d40acf80552c8fe46db481a67d534 (patch) | |
tree | a30d2652c168e32da029f3e37146967b70d9b5dc /yaksh/middleware | |
parent | e8573822d3ed25306d5d2faf946633f2c17997b0 (diff) | |
parent | 1efa4389e9d6e57315441d190da324101fd0c463 (diff) | |
download | online_test-193326ebc49d40acf80552c8fe46db481a67d534.tar.gz online_test-193326ebc49d40acf80552c8fe46db481a67d534.tar.bz2 online_test-193326ebc49d40acf80552c8fe46db481a67d534.zip |
Merge pull request #676 from adityacp/fix_middleware
Fix custom middleware according to django 3
Diffstat (limited to 'yaksh/middleware')
-rw-r--r-- | yaksh/middleware/one_session_per_user.py | 15 | ||||
-rw-r--r-- | yaksh/middleware/user_time_zone.py | 11 |
2 files changed, 15 insertions, 11 deletions
diff --git a/yaksh/middleware/one_session_per_user.py b/yaksh/middleware/one_session_per_user.py index 3b8d302..114c92b 100644 --- a/yaksh/middleware/one_session_per_user.py +++ b/yaksh/middleware/one_session_per_user.py @@ -25,14 +25,8 @@ class OneSessionPerUserMiddleware(object): self.get_response = get_response def __call__(self, request): - return self.get_response(request) - - def process_request(self, request): - """ - # Documentation: - # https://docs.djangoproject.com/en/1.5/topics/auth/customizing/ - #extending-the-existing-user-model - """ + # Code to be executed for each request before + # the view (and later middleware) are called. if isinstance(request.user, User): current_key = request.session.session_key if hasattr(request.user, 'concurrentuser'): @@ -46,3 +40,8 @@ class OneSessionPerUserMiddleware(object): concurrent_user=request.user, session_key=current_key, ) + + response = self.get_response(request) + # Code to be executed for each request/response after + # the view is called. + return response diff --git a/yaksh/middleware/user_time_zone.py b/yaksh/middleware/user_time_zone.py index 92035e8..8140851 100644 --- a/yaksh/middleware/user_time_zone.py +++ b/yaksh/middleware/user_time_zone.py @@ -12,12 +12,17 @@ class TimezoneMiddleware(object): self.get_response = get_response def __call__(self, request): - return self.get_response(request) - - def process_request(self, request): + # Code to be executed for each request before + # the view (and later middleware) are called. user = request.user user_tz = 'Asia/Kolkata' if hasattr(user, 'profile'): if user.profile.timezone: user_tz = user.profile.timezone timezone.activate(pytz.timezone(user_tz)) + + response = self.get_response(request) + + # Code to be executed for each request/response after + # the view is called. + return response |