remove email_change code
parent
df443b41a5
commit
11390f6f41
|
@ -1,32 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This file is part of django-email-change.
|
|
||||||
#
|
|
||||||
# django-email-change adds support for email address change and confirmation.
|
|
||||||
#
|
|
||||||
# Development Web Site:
|
|
||||||
# - http://www.codetrax.org/projects/django-email-change
|
|
||||||
# Public Source Code Repository:
|
|
||||||
# - https://source.codetrax.org/hgroot/django-email-change
|
|
||||||
#
|
|
||||||
# Copyright 2010 George Notaras <gnot [at] g-loaded.eu>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
VERSION = (0, 2, 2, 'final', 0)
|
|
||||||
|
|
||||||
def get_version():
|
|
||||||
version = '%d.%d.%d' % (VERSION[0], VERSION[1], VERSION[2])
|
|
||||||
return version
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This file is part of django-email-change.
|
|
||||||
#
|
|
||||||
# django-email-change adds support for email address change and confirmation.
|
|
||||||
#
|
|
||||||
# Development Web Site:
|
|
||||||
# - http://www.codetrax.org/projects/django-email-change
|
|
||||||
# Public Source Code Repository:
|
|
||||||
# - https://source.codetrax.org/hgroot/django-email-change
|
|
||||||
#
|
|
||||||
# Copyright 2010 George Notaras <gnot [at] g-loaded.eu>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
from django.contrib import admin
|
|
||||||
from django.db.models.loading import cache
|
|
||||||
|
|
||||||
class EmailChangeRequestAdmin(admin.ModelAdmin):
|
|
||||||
raw_id_fields = ('user',)
|
|
||||||
|
|
||||||
admin.site.register(cache.get_model('email_change', 'EmailChangeRequest'), EmailChangeRequestAdmin)
|
|
|
@ -1,71 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This file is part of django-email-change.
|
|
||||||
#
|
|
||||||
# django-email-change adds support for email address change and confirmation.
|
|
||||||
#
|
|
||||||
# Development Web Site:
|
|
||||||
# - http://www.codetrax.org/projects/django-email-change
|
|
||||||
# Public Source Code Repository:
|
|
||||||
# - https://source.codetrax.org/hgroot/django-email-change
|
|
||||||
#
|
|
||||||
# Copyright 2010 George Notaras <gnot [at] g-loaded.eu>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
from django import forms
|
|
||||||
from django.db.models.loading import cache
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
|
|
||||||
|
|
||||||
class EmailChangeForm(forms.Form):
|
|
||||||
|
|
||||||
email = forms.EmailField(label='New E-mail', max_length=75)
|
|
||||||
|
|
||||||
def __init__(self, username=None, *args, **kwargs):
|
|
||||||
"""Constructor.
|
|
||||||
|
|
||||||
**Mandatory arguments**
|
|
||||||
|
|
||||||
``username``
|
|
||||||
The username of the user that requested the email change.
|
|
||||||
|
|
||||||
"""
|
|
||||||
self.username = username
|
|
||||||
super(EmailChangeForm, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def clean_email(self):
|
|
||||||
"""Checks whether the new email address differs from the user's current
|
|
||||||
email address.
|
|
||||||
|
|
||||||
"""
|
|
||||||
email = self.cleaned_data.get('email')
|
|
||||||
|
|
||||||
User = cache.get_model('auth', 'User')
|
|
||||||
user = User.objects.get(username__exact=self.username)
|
|
||||||
|
|
||||||
# Check if the new email address differs from the current email address.
|
|
||||||
if user.email == email:
|
|
||||||
raise forms.ValidationError(_("Your email is already ")+ email)
|
|
||||||
|
|
||||||
users = User.objects.exclude(id=user.id).filter(email__iexact=email)
|
|
||||||
for user in users:
|
|
||||||
raise forms.ValidationError(_("Another user with that email already exists."))
|
|
||||||
|
|
||||||
return email
|
|
||||||
|
|
||||||
oldemail = None
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -1,141 +0,0 @@
|
||||||
# SOME DESCRIPTIVE TITLE.
|
|
||||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
|
||||||
# This file is distributed under the same license as the PACKAGE package.
|
|
||||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
||||||
#
|
|
||||||
#, fuzzy
|
|
||||||
msgid ""
|
|
||||||
msgstr ""
|
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
|
||||||
"Report-Msgid-Bugs-To: \n"
|
|
||||||
"POT-Creation-Date: 2011-02-23 18:25+0200\n"
|
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
||||||
"Language: \n"
|
|
||||||
"MIME-Version: 1.0\n"
|
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_change_complete.html.py:4
|
|
||||||
#: .\templates\email_change\email_change_complete.html.py:13
|
|
||||||
msgid "Email change complete"
|
|
||||||
msgstr "Αλλαγή διεύθυνσης email ολοκληρώθηκε"
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_change_complete.html.py:7
|
|
||||||
#: .\templates\email_change\email_verification_sent.html.py:7
|
|
||||||
#: .\templates\email_change\email_verify.html.py:7
|
|
||||||
msgid "Notice"
|
|
||||||
msgstr "Σημείωση"
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_change_complete.html.py:18
|
|
||||||
msgid "Your email address has been changed successfully."
|
|
||||||
msgstr "Η διεύθυνση email σας έχει αλλάξει επιτυχώς."
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_change_complete.html.py:19
|
|
||||||
msgid "Your new email address is:"
|
|
||||||
msgstr "Η νέα διεύθυνση email είναι:"
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_change_complete.html.py:21
|
|
||||||
#: .\templates\email_change\email_change_form.html.py:25
|
|
||||||
#: .\templates\email_change\email_verification_sent.html.py:20
|
|
||||||
#: .\templates\email_change\email_verify.html.py:21
|
|
||||||
msgid "Back to your profile"
|
|
||||||
msgstr "Πίσω στο προφίλ σας"
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_change_form.html.py:4
|
|
||||||
#: .\templates\email_change\email_change_form.html.py:7
|
|
||||||
#: .\templates\email_change\email_change_form.html.py:13
|
|
||||||
#: .\templates\email_change\email_change_form.html.py:23
|
|
||||||
msgid "Change email address"
|
|
||||||
msgstr "Αλλαγή διεύθυνσης email"
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_change_form.html.py:18
|
|
||||||
msgid "Your current email address is:"
|
|
||||||
msgstr "Η τωρινή διεύθυνση email σας είναι:"
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_change_form.html.py:20
|
|
||||||
msgid ""
|
|
||||||
"To associate a new email address with your account, please enter the new "
|
|
||||||
"address in the box below."
|
|
||||||
msgstr "Για να συσχετίσεται μια νέα διεύθυνση email με το λογαριασμό σας, παρακαλούμε εισάγετε τη νέα διεύθυνση παρακάτω."
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_verification_sent.html.py:4
|
|
||||||
#: .\templates\email_change\email_verification_sent.html.py:13
|
|
||||||
msgid "Verification email sent"
|
|
||||||
msgstr "Email επαλήθευσης στάλθηκε"
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_verification_sent.html.py:18
|
|
||||||
msgid ""
|
|
||||||
"An email containing a verification link has been sent to your new email "
|
|
||||||
"address."
|
|
||||||
msgstr "Ένα email που περιέχει έναν σύνδεσμο για επαλήθευση σας έχει αποσταλεί στη νέα διεύθυνση."
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_verification_sent.html.py:19
|
|
||||||
msgid ""
|
|
||||||
"Follow the instructions in this email in order to successfully change your "
|
|
||||||
"current email address."
|
|
||||||
msgstr "Ακολουθήστε τις οδηγίες αυτού του μηνύματος προκειμένου να αλλάξετε επιτυχώς την τωρινή σας διεύθυνση."
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_verify.html.py:4
|
|
||||||
msgid "Email confirmation"
|
|
||||||
msgstr "Επιβεβαίωση διεύθυνσης email"
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_verify.html.py:13
|
|
||||||
msgid "Email confirmation failed"
|
|
||||||
msgstr "Επιβεβαίωση διεύθυνσης email απέτυχε"
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_verify.html.py:18
|
|
||||||
msgid "This confirmation code has either expired or is invalid."
|
|
||||||
msgstr "Αυτός ο κωδικός επιβεβαίωσης έχει λήξει ή είναι άκυρος."
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_verify.html.py:19
|
|
||||||
msgid "The requested email address change has failed."
|
|
||||||
msgstr "Το αίτημα για αλλαγή της διεύθυνσης email απέτυχε."
|
|
||||||
|
|
||||||
#: .\templates\email_change\email_verify.html.py:20
|
|
||||||
msgid "Please, try to change it again in your account settings."
|
|
||||||
msgstr "Παρακαλούμε, επιχειρήστε να το αλλάξετε ξανά στις ρυθμίσεις του λογαριασμού σας."
|
|
||||||
|
|
||||||
#: .\templates\email_change\emails\verification_email_message.html.py:2
|
|
||||||
msgid "Hi"
|
|
||||||
msgstr "Γεια"
|
|
||||||
|
|
||||||
#: .\templates\email_change\emails\verification_email_message.html.py:4
|
|
||||||
#, python-format
|
|
||||||
msgid ""
|
|
||||||
"A request to change the email address of your account has been made at "
|
|
||||||
"%(site_name)s."
|
|
||||||
msgstr "Ένα αίτημα για αλλαγή της διεύθυνσης email του λογαριασμού σας έχει γίνει στο %(site_name)s."
|
|
||||||
|
|
||||||
#: .\templates\email_change\emails\verification_email_message.html.py:6
|
|
||||||
msgid ""
|
|
||||||
"Before changing your current email address, verification of your new email "
|
|
||||||
"address is required."
|
|
||||||
msgstr "Πριν αλλάξετε την τρέχουσα διεύθυνση email, η επαλήθευση της νέας διεύθυνσης email είναι απαραίτητη."
|
|
||||||
|
|
||||||
#: .\templates\email_change\emails\verification_email_message.html.py:8
|
|
||||||
msgid ""
|
|
||||||
"To complete the email change, please visit the following URL, either by "
|
|
||||||
"clicking on it or by copying and pasting it in your browser:"
|
|
||||||
msgstr "Για να ολοκληρώσετε την αλλαγή της διεύθυνσης email, παρακαλούμε επισκευτείτε την παρακάτω διεύθυνση είτε κάνοντας κλικ πάνω της είτε αντιγράφοντάς την και επικολλώντας την στον φυλομετρητή σας:"
|
|
||||||
|
|
||||||
#: .\templates\email_change\emails\verification_email_message.html.py:12
|
|
||||||
msgid "You will only need to visit this URL once."
|
|
||||||
msgstr "Χρειάζετε να επισκευτείτε αυτή τη διεύθυνση μόνο μία φορά."
|
|
||||||
|
|
||||||
#: .\templates\email_change\emails\verification_email_message.html.py:14
|
|
||||||
msgid "Thank you"
|
|
||||||
msgstr "Ευχαριστούμε"
|
|
||||||
|
|
||||||
#: .\templates\email_change\emails\verification_email_message.html.py:16
|
|
||||||
#, python-format
|
|
||||||
msgid "The Team at %(site_name)s"
|
|
||||||
msgstr "Η μάδα του %(site_name)s"
|
|
||||||
|
|
||||||
#: .\templates\email_change\emails\verification_email_subject.html.py:1
|
|
||||||
#, python-format
|
|
||||||
msgid "Email change verification for %(site_name)s"
|
|
||||||
msgstr "Επιβεβαίωση αλλαγής διεύθυνσης email στο %(site_name)s"
|
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This file is part of django-email-change.
|
|
||||||
#
|
|
||||||
# django-email-change adds support for email address change and confirmation.
|
|
||||||
#
|
|
||||||
# Development Web Site:
|
|
||||||
# - http://www.codetrax.org/projects/django-email-change
|
|
||||||
# Public Source Code Repository:
|
|
||||||
# - https://source.codetrax.org/hgroot/django-email-change
|
|
||||||
#
|
|
||||||
# Copyright 2010 George Notaras <gnot [at] g-loaded.eu>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
from email_change import settings
|
|
||||||
|
|
||||||
|
|
||||||
class EmailChangeRequest(models.Model):
|
|
||||||
user = models.ForeignKey('auth.User', unique=True, related_name='%(class)s_user')
|
|
||||||
verification_key = models.CharField(max_length=40)
|
|
||||||
email = models.EmailField(max_length=75) # Contains the new email address
|
|
||||||
date_created = models.DateTimeField(auto_now_add=True)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = 'email change request'
|
|
||||||
verbose_name_plural = 'email change requests'
|
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
return '(%s) %s --> %s' % (self.user.username, self.user.email, self.email)
|
|
||||||
|
|
||||||
def has_expired(self):
|
|
||||||
dt = datetime.timedelta(days=settings.EMAIL_CHANGE_VERIFICATION_DAYS)
|
|
||||||
expiration_date = self.date_created + dt
|
|
||||||
return expiration_date <= datetime.datetime.now()
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This file is part of django-email-change.
|
|
||||||
#
|
|
||||||
# django-email-change adds support for email address change and confirmation.
|
|
||||||
#
|
|
||||||
# Development Web Site:
|
|
||||||
# - http://www.codetrax.org/projects/django-email-change
|
|
||||||
# Public Source Code Repository:
|
|
||||||
# - https://source.codetrax.org/hgroot/django-email-change
|
|
||||||
#
|
|
||||||
# Copyright 2010 George Notaras <gnot [at] g-loaded.eu>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
|
|
||||||
EMAIL_CHANGE_VERIFICATION_DAYS = getattr(settings, 'EMAIL_CHANGE_VERIFICATION_DAYS', 7)
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This file is part of django-email-change.
|
|
||||||
#
|
|
||||||
# django-email-change adds support for email address change and confirmation.
|
|
||||||
#
|
|
||||||
# Development Web Site:
|
|
||||||
# - http://www.codetrax.org/projects/django-email-change
|
|
||||||
# Public Source Code Repository:
|
|
||||||
# - https://source.codetrax.org/hgroot/django-email-change
|
|
||||||
#
|
|
||||||
# Copyright 2010 George Notaras <gnot [at] g-loaded.eu>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
from django.db.models.loading import cache
|
|
||||||
|
|
||||||
|
|
||||||
def signal_callback(sender, **kwargs):
|
|
||||||
instance = kwargs['instance'] # app_label.ModelName instance
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
{% extends "registration/registration_base.html" %}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% block doccontent %}
|
|
||||||
{% block ce_content %}{% endblock %}
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h2>Other Account Tools</h2>
|
|
||||||
<ul>
|
|
||||||
<li>Want to <a href="{% url auth_password_change %}">change your password</a>?</li>
|
|
||||||
<li>... or <a href="{% url manage_account %}">manage your pledges and payment info</a>?</li>
|
|
||||||
<li>... or <a href="{% url regluit.frontend.views.edit_user %}"">change your username</a>?</li>
|
|
||||||
<li>... or <a href="{% url notification_notice_settings %}">manage your contact preferences</a>?</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -1,16 +0,0 @@
|
||||||
{% extends "email_change/base.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block title %}{% trans "Email change complete" %}{% endblock %}
|
|
||||||
|
|
||||||
|
|
||||||
{% block ce_content %}
|
|
||||||
<h2>{% trans "Email change complete" %}</h2>
|
|
||||||
<div id="content-main">
|
|
||||||
<p>{% trans "Your email address has been changed successfully." %}</p>
|
|
||||||
<p>{% trans "Your new email address is:" %}</p>
|
|
||||||
<blockquote>{{ user.email }}</blockquote>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
{% extends "email_change/base.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block title %}{% trans "Change email address" %}{% endblock %}
|
|
||||||
|
|
||||||
|
|
||||||
{% block ce_content %}
|
|
||||||
<h2>{% trans "Change email address" %}</h2>
|
|
||||||
<div id="content-main">
|
|
||||||
<p>{% trans "Your current email address is:" %}</p>
|
|
||||||
<blockquote>{{ user.email }}</blockquote>
|
|
||||||
<p>{% trans "To associate a new email address with your account, please enter the new address in the box below." %}</p>
|
|
||||||
<form method="post">{% csrf_token %}
|
|
||||||
{{ form.as_p }}
|
|
||||||
<p><label> </label><input type="submit" value="{% trans "Change email address" %}" /></p>
|
|
||||||
</form>
|
|
||||||
<script type="text/javascript">
|
|
||||||
document.getElementById('id_email').focus()
|
|
||||||
</script>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{% extends "email_change/base.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block title %}{% trans "Verification email sent" %}{% endblock %}
|
|
||||||
|
|
||||||
|
|
||||||
{% block ce_content %}
|
|
||||||
<h2>{% trans "Verification email sent" %}</h2>
|
|
||||||
<div id="content-main">
|
|
||||||
<p>{% trans "An email containing a verification link has been sent to your new email address." %}</p>
|
|
||||||
<p>{% trans "Follow the instructions in this email in order to successfully change your current email address." %}</p>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
{% extends "email_change/base.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block title %}{% trans "Email confirmation" %}{% endblock %}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% block ce_content %}
|
|
||||||
<h2>{% trans "Email confirmation failed" %}</h2>
|
|
||||||
<div id="content-main">
|
|
||||||
<p>{% trans "This confirmation code has either expired or is invalid." %}</p>
|
|
||||||
<p>{% trans "The requested email address change has failed." %}</p>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
{% load i18n %}{% autoescape off %}
|
|
||||||
{% trans "Hi" %} {% firstof user.get_full_name user.username %},
|
|
||||||
|
|
||||||
{% blocktrans %}A request to change the email address of your account has been made at {{ site_name }}.{% endblocktrans %}
|
|
||||||
|
|
||||||
{% blocktrans %}Before changing your current email address, verification of your new email address is required.{% endblocktrans %}
|
|
||||||
|
|
||||||
{% blocktrans %}To complete the email change, please visit the following URL, either by clicking on it or by copying and pasting it in your browser:{% endblocktrans %}
|
|
||||||
|
|
||||||
{{ protocol }}://{{ site_domain }}{% url email_verify verification_key %}
|
|
||||||
|
|
||||||
{% blocktrans %}You will only need to visit this URL once.{% endblocktrans %}
|
|
||||||
|
|
||||||
{% trans "Thank you" %}
|
|
||||||
--
|
|
||||||
{% blocktrans %}The Team at {{ site_name }}{% endblocktrans %}
|
|
||||||
{% endautoescape %}
|
|
|
@ -1 +0,0 @@
|
||||||
{% load i18n %}{% blocktrans %}Email change verification for {{ site_name }}{% endblocktrans %}
|
|
|
@ -1,49 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This file is part of django-email-change.
|
|
||||||
#
|
|
||||||
# django-email-change adds support for email address change and confirmation.
|
|
||||||
#
|
|
||||||
# Development Web Site:
|
|
||||||
# - http://www.codetrax.org/projects/django-email-change
|
|
||||||
# Public Source Code Repository:
|
|
||||||
# - https://source.codetrax.org/hgroot/django-email-change
|
|
||||||
#
|
|
||||||
# Copyright 2010 George Notaras <gnot [at] g-loaded.eu>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
|
||||||
This file demonstrates two different styles of tests (one doctest and one
|
|
||||||
unittest). These will both pass when you run "manage.py test".
|
|
||||||
|
|
||||||
Replace these with more appropriate tests for your application.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
class SimpleTest(TestCase):
|
|
||||||
def test_basic_addition(self):
|
|
||||||
"""
|
|
||||||
Tests that 1 + 1 always equals 2.
|
|
||||||
"""
|
|
||||||
self.failUnlessEqual(1 + 1, 2)
|
|
||||||
|
|
||||||
__test__ = {"doctest": """
|
|
||||||
Another way to test that 1 + 1 is equal to 2.
|
|
||||||
|
|
||||||
>>> 1 + 1 == 2
|
|
||||||
True
|
|
||||||
"""}
|
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This file is part of django-email-change.
|
|
||||||
#
|
|
||||||
# django-email-change adds support for email address change and confirmation.
|
|
||||||
#
|
|
||||||
# Development Web Site:
|
|
||||||
# - http://www.codetrax.org/projects/django-email-change
|
|
||||||
# Public Source Code Repository:
|
|
||||||
# - https://source.codetrax.org/hgroot/django-email-change
|
|
||||||
#
|
|
||||||
# Copyright 2010 George Notaras <gnot [at] g-loaded.eu>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
from django.conf.urls.defaults import *
|
|
||||||
from django.views.generic.simple import direct_to_template
|
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
|
||||||
url(r'^email/change/$', 'email_change.views.email_change_view', name='email_change'),
|
|
||||||
url(r'^email/verification/sent/$',
|
|
||||||
direct_to_template, {'template': 'email_change/email_verification_sent.html'},
|
|
||||||
name='email_verification_sent'),
|
|
||||||
# Note taken from django-registration
|
|
||||||
# Verification keys get matched by \w+ instead of the more specific
|
|
||||||
# [a-fA-F0-9]{40} because a bad verification key should still get to the view;
|
|
||||||
# that way it can return a sensible "invalid key" message instead of a
|
|
||||||
# confusing 404.
|
|
||||||
url(r'^email/verify/(?P<verification_key>\w+)/$', 'email_change.views.email_verify_view', name='email_verify'),
|
|
||||||
url(r'^email/change/complete/$',
|
|
||||||
direct_to_template, {'template': 'email_change/email_change_complete.html'},
|
|
||||||
name='email_change_complete'),
|
|
||||||
)
|
|
|
@ -1,46 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This file is part of django-email-change.
|
|
||||||
#
|
|
||||||
# django-email-change adds support for email address change and confirmation.
|
|
||||||
#
|
|
||||||
# Development Web Site:
|
|
||||||
# - http://www.codetrax.org/projects/django-email-change
|
|
||||||
# Public Source Code Repository:
|
|
||||||
# - https://source.codetrax.org/hgroot/django-email-change
|
|
||||||
#
|
|
||||||
# Copyright 2010 George Notaras <gnot [at] g-loaded.eu>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
import random
|
|
||||||
from django.contrib.auth.tokens import default_token_generator
|
|
||||||
from django.utils.hashcompat import sha_constructor
|
|
||||||
|
|
||||||
|
|
||||||
def generate_key(user, email):
|
|
||||||
"""Generates and returns unique keys.
|
|
||||||
|
|
||||||
**Arguments**
|
|
||||||
|
|
||||||
``user``
|
|
||||||
auth.User instance
|
|
||||||
``email``
|
|
||||||
The new email address
|
|
||||||
|
|
||||||
"""
|
|
||||||
return sha_constructor(
|
|
||||||
default_token_generator.make_token(user) + email + str(random.random())
|
|
||||||
).hexdigest()
|
|
||||||
|
|
|
@ -1,139 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This file is part of django-email-change.
|
|
||||||
#
|
|
||||||
# django-email-change adds support for email address change and confirmation.
|
|
||||||
#
|
|
||||||
# Development Web Site:
|
|
||||||
# - http://www.codetrax.org/projects/django-email-change
|
|
||||||
# Public Source Code Repository:
|
|
||||||
# - https://source.codetrax.org/hgroot/django-email-change
|
|
||||||
#
|
|
||||||
# Copyright 2010 George Notaras <gnot [at] g-loaded.eu>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
from django.contrib.auth.decorators import login_required
|
|
||||||
from django.shortcuts import render_to_response, redirect
|
|
||||||
from django.db.models.loading import cache
|
|
||||||
from django.template import RequestContext, Context
|
|
||||||
from django.template.loader import render_to_string
|
|
||||||
from django.core.mail import send_mail
|
|
||||||
|
|
||||||
from email_change.forms import EmailChangeForm
|
|
||||||
from email_change.utils import generate_key
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
def email_change_view(request, extra_context={},
|
|
||||||
success_url='email_verification_sent',
|
|
||||||
template_name='email_change/email_change_form.html',
|
|
||||||
email_message_template_name='email_change/emails/verification_email_message.html',
|
|
||||||
email_subject_template_name='email_change/emails/verification_email_subject.html'):
|
|
||||||
"""Allow a user to change the email address associated with the user account.
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
if request.method == 'POST':
|
|
||||||
form = EmailChangeForm(username=request.user.username, data=request.POST, files=request.FILES)
|
|
||||||
if form.is_valid():
|
|
||||||
|
|
||||||
EmailChangeRequest = cache.get_model('email_change', 'EmailChangeRequest')
|
|
||||||
Site = cache.get_model('sites', 'Site')
|
|
||||||
|
|
||||||
email = form.cleaned_data.get('email')
|
|
||||||
verification_key = generate_key(request.user, email)
|
|
||||||
|
|
||||||
current_site = Site.objects.get_current()
|
|
||||||
site_name = current_site.name
|
|
||||||
domain = current_site.domain
|
|
||||||
|
|
||||||
protocol = 'http'
|
|
||||||
if request.is_secure():
|
|
||||||
protocol = 'https'
|
|
||||||
|
|
||||||
# First clean all email change requests made by this user
|
|
||||||
qs = EmailChangeRequest.objects.filter(user=request.user)
|
|
||||||
qs.delete()
|
|
||||||
|
|
||||||
# Create an email change request
|
|
||||||
EmailChangeRequest.objects.create(
|
|
||||||
user = request.user,
|
|
||||||
verification_key = verification_key,
|
|
||||||
email = email
|
|
||||||
)
|
|
||||||
old_email=request.user.email
|
|
||||||
|
|
||||||
# Prepare context
|
|
||||||
c = {
|
|
||||||
'email': email,
|
|
||||||
'site_domain': domain,
|
|
||||||
'site_name': site_name,
|
|
||||||
'user': request.user,
|
|
||||||
'verification_key': verification_key,
|
|
||||||
'protocol': protocol,
|
|
||||||
}
|
|
||||||
c.update(extra_context)
|
|
||||||
context = Context(c)
|
|
||||||
|
|
||||||
# Send success email
|
|
||||||
subject = render_to_string(email_subject_template_name, context_instance=context)
|
|
||||||
message = render_to_string(email_message_template_name, context_instance=context)
|
|
||||||
|
|
||||||
send_mail(subject, message, None, [email, old_email])
|
|
||||||
|
|
||||||
# Redirect
|
|
||||||
return redirect(success_url)
|
|
||||||
|
|
||||||
else:
|
|
||||||
form = EmailChangeForm(username=request.user.username)
|
|
||||||
|
|
||||||
context = RequestContext(request, extra_context)
|
|
||||||
context['form'] = form
|
|
||||||
|
|
||||||
return render_to_response(template_name, context_instance=context)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
def email_verify_view(request, verification_key, extra_context={},
|
|
||||||
success_url='email_change_complete',
|
|
||||||
template_name='email_change/email_verify.html'):
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
EmailChangeRequest = cache.get_model('email_change', 'EmailChangeRequest')
|
|
||||||
context = RequestContext(request, extra_context)
|
|
||||||
try:
|
|
||||||
ecr = EmailChangeRequest.objects.get(
|
|
||||||
user=request.user, verification_key=verification_key)
|
|
||||||
except EmailChangeRequest.DoesNotExist:
|
|
||||||
# Return failure response
|
|
||||||
return render_to_response(template_name, context_instance=context)
|
|
||||||
else:
|
|
||||||
# Check if the email change request has expired
|
|
||||||
if ecr.has_expired():
|
|
||||||
ecr.delete()
|
|
||||||
# Return failure response
|
|
||||||
return render_to_response(template_name, context_instance=context)
|
|
||||||
|
|
||||||
# Success. Replace the user's email with the new email
|
|
||||||
request.user.email = ecr.email
|
|
||||||
request.user.save()
|
|
||||||
|
|
||||||
# Delete the email change request
|
|
||||||
ecr.delete()
|
|
||||||
|
|
||||||
# Redirect to success URL
|
|
||||||
return redirect(success_url)
|
|
||||||
|
|
Loading…
Reference in New Issue