On 5/15/07, Christian M Hoeppner <[EMAIL PROTECTED]> wrote:
...
> Of course, this would work, but it also prevents users not logged in from
> logging in. Is there a way to check if the user is accessing the login view,
> in order to let him access his account and the site being under maintenance?
You're more likely to get working code if all the requirements are stated. :)
Set these settings:
LOGIN_REDIRECT_URL
LOGIN_URL
LOGOUT_URL
Then the middleware would be:
class MaintenanceMiddleware(object):
def process_request(self, request):
from django.conf import settings
from django.http import HttpResponseRedirect
is_login = request.path in (
settings.LOGIN_REDIRECT_URL,
settings.LOGIN_URL,
settings.LOGOUT_URL)
if ((not is_login) and
settings.MAINTENANCE and
(not request.user.is_authenticated())):
return HttpResponseRedirect("/maintenance/")
return None
More:
http://www.djangoproject.com/documentation/request_response/#attributes
http://www.djangoproject.com/documentation/settings/#login-redirect-url
Note that those settings are new in the Django dev version (after
0.96). Of course you could add them to your own settings file, same
as MAINTENANCE.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---