mirror of
https://github.com/c0de-archive/django-gallery.git
synced 2024-12-22 10:12:41 +00:00
test
This commit is contained in:
parent
b1b9bc4ce2
commit
d82bcffab5
@ -27,6 +27,15 @@ class Account(models.Model):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "<%s:%s>" % (self.id, self.user.username)
|
return "<%s:%s>" % (self.id, self.user.username)
|
||||||
|
|
||||||
|
def get_meta(self):
|
||||||
|
meta = {
|
||||||
|
'user': self.user.username,
|
||||||
|
'first_login': self.first_login,
|
||||||
|
'accepted_terms': self.accepted_terms
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta
|
||||||
|
|
||||||
def create_user(self, username, first_name, last_name, email, password):
|
def create_user(self, username, first_name, last_name, email, password):
|
||||||
# Create a user
|
# Create a user
|
||||||
usr_obj = User.objects.get_or_create(username=username,
|
usr_obj = User.objects.get_or_create(username=username,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.template import loader
|
from django.template import loader
|
||||||
from django.contrib import auth
|
from django.contrib import auth
|
||||||
|
import logging
|
||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
# template - relative path to the template you wish to render
|
# template - relative path to the template you wish to render
|
||||||
@ -15,6 +16,7 @@ def _ResponseTemplate(template, request, message='', context=None):
|
|||||||
(context.get('message', False)):
|
(context.get('message', False)):
|
||||||
context['message'] += ' -- ' + str(message)
|
context['message'] += ' -- ' + str(message)
|
||||||
else:
|
else:
|
||||||
|
logging.warning('[_ResponseTemplate]: context was %s, not a dictionary like expected. Ignoring provided context' % type(context))
|
||||||
context = {
|
context = {
|
||||||
'message': str(message)
|
'message': str(message)
|
||||||
}
|
}
|
||||||
@ -25,5 +27,7 @@ def _ResponseTemplate(template, request, message='', context=None):
|
|||||||
# Logs out a user, sending them to the login screen with an optional message and context
|
# Logs out a user, sending them to the login screen with an optional message and context
|
||||||
# Same arguments as _ResponseTemplate, except for the template
|
# Same arguments as _ResponseTemplate, except for the template
|
||||||
def _ForceLogout(request, message='', context=None):
|
def _ForceLogout(request, message='', context=None):
|
||||||
|
if request.user:
|
||||||
|
logging.debug('Logged out %s' % request.user)
|
||||||
auth.logout(request)
|
auth.logout(request)
|
||||||
return _ResponseTemplate('account/login.html', request, message, context)
|
return _ResponseTemplate('account/login.html', request, message, context)
|
||||||
|
Loading…
Reference in New Issue
Block a user