mirror of
https://github.com/c0de-archive/django-gallery.git
synced 2024-12-22 02:02:40 +00:00
test
This commit is contained in:
parent
b1b9bc4ce2
commit
d82bcffab5
@ -27,6 +27,15 @@ class Account(models.Model):
|
||||
def __str__(self):
|
||||
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):
|
||||
# Create a user
|
||||
usr_obj = User.objects.get_or_create(username=username,
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django.http import HttpResponse
|
||||
from django.template import loader
|
||||
from django.contrib import auth
|
||||
import logging
|
||||
|
||||
# Usage:
|
||||
# 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['message'] += ' -- ' + str(message)
|
||||
else:
|
||||
logging.warning('[_ResponseTemplate]: context was %s, not a dictionary like expected. Ignoring provided context' % type(context))
|
||||
context = {
|
||||
'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
|
||||
# Same arguments as _ResponseTemplate, except for the template
|
||||
def _ForceLogout(request, message='', context=None):
|
||||
if request.user:
|
||||
logging.debug('Logged out %s' % request.user)
|
||||
auth.logout(request)
|
||||
return _ResponseTemplate('account/login.html', request, message, context)
|
||||
|
Loading…
Reference in New Issue
Block a user