mirror of
https://github.com/krislamo/DJ-BaseSite
synced 2024-11-09 23:00:34 +00:00
Added custom title pages.
Added variable: "basetitle" to the config file which sets the title on index, login and registration pages as well as the admin pages. I then moved the code that connects to the SMTP server to above where the user is created in registration. I did this because if the connection fails then it wont continue and create a user that wont be able get an activation link. I also adjusted some indentions to make it easier to read on github.com
This commit is contained in:
parent
b8d3c338f8
commit
782a6e15d2
21
config.txt
21
config.txt
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
// CUSTOM VARIABLES
|
// CUSTOM VARIABLES
|
||||||
v baseurl http://127.0.0.1:8000
|
v baseurl http://127.0.0.1:8000
|
||||||
|
v basetitle DJ-BaseSite
|
||||||
|
|
||||||
v admin_name Kris619
|
v admin_name Kris619
|
||||||
v admin_email KrisPublicEmail@gmail.com
|
v admin_email KrisPublicEmail@gmail.com
|
||||||
@ -38,7 +39,9 @@ v HOSTpass HereItIs_HaveMyAccount
|
|||||||
|
|
||||||
// !!!!!!HEY, PAY ATTENTION FOR A SECOND!!!!!!
|
// !!!!!!HEY, PAY ATTENTION FOR A SECOND!!!!!!
|
||||||
// Don't mess with anything below unless you
|
// Don't mess with anything below unless you
|
||||||
// know what you are doing.
|
// know what you are doing. You can easily
|
||||||
|
// crash the Setup by putting things in the
|
||||||
|
// wrong order.
|
||||||
|
|
||||||
// DYNAMIC FILES
|
// DYNAMIC FILES
|
||||||
%here%/myproject/manage.py 1
|
%here%/myproject/manage.py 1
|
||||||
@ -47,6 +50,14 @@ v HOSTpass HereItIs_HaveMyAccount
|
|||||||
%here%/myproject/myproject/urls.py 1
|
%here%/myproject/myproject/urls.py 1
|
||||||
%here%/myproject/manage.py 1
|
%here%/myproject/manage.py 1
|
||||||
|
|
||||||
|
// Add these dir commands before actually adding
|
||||||
|
// the files from inside the folders.
|
||||||
|
|
||||||
|
// Admin
|
||||||
|
dir templates
|
||||||
|
dir templates/admin
|
||||||
|
%here%/myproject/myproject/templates/admin/base_site.html 1
|
||||||
|
|
||||||
// STATIC FILES
|
// STATIC FILES
|
||||||
%here%/myproject/myproject/__init__.py 2
|
%here%/myproject/myproject/__init__.py 2
|
||||||
%here%/myproject/myproject/views.py 2
|
%here%/myproject/myproject/views.py 2
|
||||||
@ -58,13 +69,9 @@ v HOSTpass HereItIs_HaveMyAccount
|
|||||||
// Activation Email
|
// Activation Email
|
||||||
%here%/myproject/myproject/activation_email.html 2
|
%here%/myproject/myproject/activation_email.html 2
|
||||||
|
|
||||||
// Add these dir commands before actually adding
|
|
||||||
// the files from inside the folders.
|
|
||||||
|
|
||||||
// HTML/CSS
|
// HTML/CSS
|
||||||
dir static
|
dir static
|
||||||
dir static/css
|
dir static/css
|
||||||
dir templates
|
|
||||||
%here%/myproject/myproject/static/css/default.css 2
|
%here%/myproject/myproject/static/css/default.css 2
|
||||||
%here%/myproject/myproject/templates/base.html 2
|
%here%/myproject/myproject/templates/base.html 2
|
||||||
%here%/myproject/myproject/templates/index.html 2
|
%here%/myproject/myproject/templates/index.html 2
|
||||||
@ -80,10 +87,6 @@ dir templates/auth
|
|||||||
%here%/myproject/myproject/templates/auth/newaccount.html 2
|
%here%/myproject/myproject/templates/auth/newaccount.html 2
|
||||||
%here%/myproject/myproject/templates/auth/registration.html 2
|
%here%/myproject/myproject/templates/auth/registration.html 2
|
||||||
|
|
||||||
// Admin
|
|
||||||
dir templates/admin
|
|
||||||
%here%/myproject/myproject/templates/admin/base_site.html 2
|
|
||||||
|
|
||||||
// Backend Django app
|
// Backend Django app
|
||||||
dir backends root
|
dir backends root
|
||||||
%here%/myproject/backends/__init__.py 2
|
%here%/myproject/backends/__init__.py 2
|
||||||
|
@ -16,6 +16,7 @@ DEBUG = True
|
|||||||
TEMPLATE_DEBUG = DEBUG
|
TEMPLATE_DEBUG = DEBUG
|
||||||
|
|
||||||
baseurl = "<%baseurl%>" # "example.com"
|
baseurl = "<%baseurl%>" # "example.com"
|
||||||
|
base_title = "<%basetitle%>"
|
||||||
|
|
||||||
'''
|
'''
|
||||||
You need to sign up at http://recaptcha.net/ for a public/private key to use their CAPTCHA service.
|
You need to sign up at http://recaptcha.net/ for a public/private key to use their CAPTCHA service.
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{% extends "admin/base.html" %}
|
{% extends "admin/base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}{{ title }} | {% trans 'Admin Site' %}{% endblock %}
|
{% block title %}{{ title }} | {% trans '<%basetitle%> Admin Site' %}{% endblock %}
|
||||||
|
|
||||||
{% block branding %}
|
{% block branding %}
|
||||||
<h1 id="site-name">{% trans 'Administration' %}</h1>
|
<h1 id="site-name">{% trans '<%basetitle%> Administration' %}</h1>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block nav-global %}{% endblock %}
|
{% block nav-global %}{% endblock %}
|
||||||
|
@ -31,7 +31,8 @@ from django.core.mail import EmailMessage
|
|||||||
from django.core import mail
|
from django.core import mail
|
||||||
|
|
||||||
# Variables from Settings.py
|
# Variables from Settings.py
|
||||||
from settings import EMAIL_HOST_USER, baseurl, EMAIL_MESSAGE
|
from settings import EMAIL_HOST_USER, EMAIL_MESSAGE
|
||||||
|
from settings import baseurl, base_title
|
||||||
|
|
||||||
# User Profile model
|
# User Profile model
|
||||||
from accountprofile.models import UserProfile
|
from accountprofile.models import UserProfile
|
||||||
@ -166,10 +167,8 @@ def login_user(request):
|
|||||||
# User is logged on, don't let them login until he's logged out.
|
# User is logged on, don't let them login until he's logged out.
|
||||||
user_navigation = user_nav(request.user.username)
|
user_navigation = user_nav(request.user.username)
|
||||||
error = "You're already logged on."
|
error = "You're already logged on."
|
||||||
responce = render_to_response(
|
responce = render_to_response('error.html',locals())
|
||||||
'error.html',
|
|
||||||
locals()
|
|
||||||
)
|
|
||||||
return responce
|
return responce
|
||||||
|
|
||||||
def register_user(request):
|
def register_user(request):
|
||||||
@ -243,7 +242,12 @@ def register_user(request):
|
|||||||
captcha_test = captcha.displayhtml(
|
captcha_test = captcha.displayhtml(
|
||||||
captcha_publickey,
|
captcha_publickey,
|
||||||
False,
|
False,
|
||||||
HumanTestResult.error_code)
|
HumanTestResult.error_code
|
||||||
|
)
|
||||||
|
|
||||||
|
# Connect to SMTP server
|
||||||
|
connection = mail.get_connection()
|
||||||
|
connection.open()
|
||||||
|
|
||||||
# If no errors: create user.
|
# If no errors: create user.
|
||||||
if len(registration_errors) == 0:
|
if len(registration_errors) == 0:
|
||||||
@ -252,6 +256,7 @@ def register_user(request):
|
|||||||
email,
|
email,
|
||||||
request.POST["repassw"]
|
request.POST["repassw"]
|
||||||
)
|
)
|
||||||
|
|
||||||
new_user.is_active = True
|
new_user.is_active = True
|
||||||
new_user.save()
|
new_user.save()
|
||||||
|
|
||||||
@ -264,11 +269,14 @@ def register_user(request):
|
|||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
# User is created and saved. Send an activation link via email
|
# User is created and saved. Send an activation link via email
|
||||||
connection = mail.get_connection()
|
|
||||||
connection.open()
|
|
||||||
|
|
||||||
message_activateurl = baseurl+"/activate/?key="+str(activation_key)+"&user="+str(new_user.username)
|
# Activation link
|
||||||
message_deactivateurl = baseurl+"/deactivate/?key="+str(activation_key)+"&user="+str(new_user.username)
|
message_activateurl = baseurl+"/activate/?key="+str(activation_key)
|
||||||
|
message_activateurl = message_activateurl+"&user="+str(new_user.username)
|
||||||
|
|
||||||
|
# Deactivation link
|
||||||
|
message_deactivateurl = baseurl+"/deactivate/?key="+str(activation_key)
|
||||||
|
message_deactivateurl = message_deactivateurl+"&user="+str(new_user.username)
|
||||||
|
|
||||||
f = open(EMAIL_MESSAGE, 'r')
|
f = open(EMAIL_MESSAGE, 'r')
|
||||||
message = f.read()
|
message = f.read()
|
||||||
@ -281,7 +289,9 @@ def register_user(request):
|
|||||||
"Account Activation",
|
"Account Activation",
|
||||||
message,
|
message,
|
||||||
EMAIL_HOST_USER,
|
EMAIL_HOST_USER,
|
||||||
[new_user.email])
|
[new_user.email]
|
||||||
|
)
|
||||||
|
|
||||||
email.send()
|
email.send()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
@ -292,6 +302,7 @@ def register_user(request):
|
|||||||
locals(),
|
locals(),
|
||||||
context_instance=RequestContext(request)
|
context_instance=RequestContext(request)
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Return registration form with errors in registration_errors
|
# Return registration form with errors in registration_errors
|
||||||
responce = render_to_response(
|
responce = render_to_response(
|
||||||
@ -307,6 +318,7 @@ def register_user(request):
|
|||||||
locals(),
|
locals(),
|
||||||
context_instance=RequestContext(request)
|
context_instance=RequestContext(request)
|
||||||
)
|
)
|
||||||
|
|
||||||
# User is logged on
|
# User is logged on
|
||||||
else:
|
else:
|
||||||
user_navigation = user_nav(request.user.username)
|
user_navigation = user_nav(request.user.username)
|
||||||
|
Loading…
Reference in New Issue
Block a user