This commit is contained in:
c0de 2018-09-26 20:59:55 -05:00
parent b1b9bc4ce2
commit d82bcffab5
2 changed files with 14 additions and 1 deletions

View File

@ -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,

View File

@ -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)