Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
djnro
Commits
60a4dc45
Commit
60a4dc45
authored
Oct 24, 2012
by
Leonidas Poulopoulos
Browse files
Added registration plus templates
parent
62d0c01e
Changes
9
Hide whitespace changes
Inline
Side-by-side
accounts/views.py
View file @
60a4dc45
from
django.conf
import
settings
from
django.core.mail
import
send_mail
from
django.contrib.sites.models
import
Site
from
django.shortcuts
import
render_to_response
from
django.template.context
import
RequestContext
from
django.template.loader
import
render_to_string
from
django.utils.translation
import
ugettext_lazy
as
_
from
registration.models
import
RegistrationProfile
from
registration.views
import
activate
as
registration_activate
from
accounts.models
import
*
from
edumanage.forms
import
*
import
logging
import
os
logger
=
logging
.
getLogger
(
__name__
)
def
activate
(
request
,
activation_key
):
account
=
None
if
request
.
method
==
"GET"
:
activation_key
=
activation_key
.
lower
()
# Normalize before trying anything with it.
context
=
RequestContext
(
request
)
try
:
rp
=
RegistrationProfile
.
objects
.
get
(
activation_key
=
activation_key
)
except
RegistrationProfile
.
DoesNotExist
:
return
render_to_response
(
"registration/activate.html"
,
{
'account'
:
account
,
'expiration_days'
:
settings
.
ACCOUNT_ACTIVATION_DAYS
},
context_instance
=
context
)
try
:
userProfile
=
rp
.
user
.
get_profile
()
except
UserProfile
.
DoesNotExist
:
return
render_to_response
(
"registration/activate.html"
,
{
'account'
:
account
,
'expiration_days'
:
settings
.
ACCOUNT_ACTIVATION_DAYS
},
context_instance
=
context
)
form
=
UserProfileForm
(
instance
=
userProfile
)
form
.
fields
[
'user'
]
=
forms
.
ModelChoiceField
(
queryset
=
User
.
objects
.
filter
(
pk
=
rp
.
user
.
pk
),
empty_label
=
None
)
form
.
fields
[
'institution'
]
=
forms
.
ModelChoiceField
(
queryset
=
Institution
.
objects
.
all
(),
empty_label
=
None
)
return
render_to_response
(
"registration/activate_edit.html"
,
{
'account'
:
account
,
'expiration_days'
:
settings
.
ACCOUNT_ACTIVATION_DAYS
,
'form'
:
form
},
context_instance
=
context
)
if
request
.
method
==
"POST"
:
context
=
RequestContext
(
request
)
request_data
=
request
.
POST
.
copy
()
try
:
user
=
User
.
objects
.
get
(
pk
=
request_data
[
'user'
])
up
=
user
.
get_profile
()
up
.
institution
=
Institution
.
objects
.
get
(
pk
=
request_data
[
'institution'
])
up
.
save
()
except
:
return
render_to_response
(
"registration/activate_edit.html"
,
{
'account'
:
account
,
'expiration_days'
:
settings
.
ACCOUNT_ACTIVATION_DAYS
},
context_instance
=
context
)
activation_key
=
activation_key
.
lower
()
# Normalize before trying anything with it.
try
:
rp
=
RegistrationProfile
.
objects
.
get
(
activation_key
=
activation_key
)
account
=
RegistrationProfile
.
objects
.
activate_user
(
activation_key
)
logger
.
info
(
"Activating user %s"
%
rp
.
user
.
username
)
except
Exception
as
e
:
logger
.
info
(
"An error occured: %s"
%
e
)
pass
if
account
:
# A user has been activated
email
=
render_to_string
(
"registration/activation_complete.txt"
,
{
"site"
:
Site
.
objects
.
get_current
(),
"user"
:
account
})
send_mail
(
_
(
"%sUser account activated"
)
%
settings
.
EMAIL_SUBJECT_PREFIX
,
email
,
settings
.
SERVER_EMAIL
,
[
account
.
email
])
context
=
RequestContext
(
request
)
return
render_to_response
(
"registration/activate.html"
,
{
'account'
:
account
,
'expiration_days'
:
settings
.
ACCOUNT_ACTIVATION_DAYS
},
context_instance
=
context
)
templates/registration/activate.html
0 → 100644
View file @
60a4dc45
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Activation Complete" %}{% endblock %}
{% block topmenu %}
<ul
class=
"nav"
>
<li>
<a
href=
"{% url index %}"
>
{% trans "Home" %}
</a>
</li>
<li>
<a
href=
"/faq/{{LANGUAGE_CODE}}/"
>
FAQ
</a>
</li>
<li>
<a
href=
"{% url login %}"
style=
"padding-top: 3px; padding-bottom: 0px;"
>
{% trans "Manage" %}
<img
src=
"/static/img/image_shibboleth_logo_color.png"
style=
"padding: 0px;"
></a>
</li>
</ul>
{% endblock %}
{% block content %}
<div
class=
"container-fluid"
>
<div
class=
"row-fluid"
>
<div
class=
"span2"
>
</div>
<!--/span-->
<div
class=
"span10"
>
<div
class=
"row-fluid"
>
<!--/span-->
<h3>
{% trans "Activation Status" %}
</h3>
<hr>
{% block subcontent %}
<div
class=
"span10 alert {% if account %}alert-success{% else %}alert-info{% endif %}"
>
{% if account %}
{{account}} {% trans "succesfully activated" %}
{% else %}
{% trans "The user has probably been already activated." %}
{% endif %}
</div>
{% endblock %}
<!--/span-->
</div>
<!--/row-->
</div>
<!--/span-->
</div>
<!--/span-->
<hr>
<footer>
<p>
©
@ GRNET NOC 2012
</p>
</footer>
</div>
<!--/.fluid-container-->
{% endblock %}
\ No newline at end of file
templates/registration/activate_edit.html
0 → 100644
View file @
60a4dc45
{% extends "base.html" %}
{% load i18n %}
{% block content %}
<div
class=
"container-fluid"
>
<div
class=
"row-fluid"
>
<div
class=
"span2"
>
</div>
<!--/span-->
<div
class=
"span10"
>
<div
class=
"row-fluid"
>
<!--/span-->
<div
class=
"span10"
>
<h4>
User activation details
</h4>
<hr>
<div
class=
"span1"
></div>
<div
class=
"span7"
>
</div>
<div
class=
"span12"
></div>
<div
class=
"span12"
>
<form
method=
"POST"
class=
"form-horizontal"
>
{% csrf_token %}
{% if form.non_field_errors %}
<p
class=
"error"
>
{{ form.non_field_errors}}
</p>
{% endif %}
<div
class=
"control-group {% if form.user.errors %} error {% endif %}"
>
<label
class=
"control-label"
for=
"id_user"
><b>
{% trans "User" %}
</b></label>
<div
class=
"controls"
>
{{ form.user }}
{% if form.user.errors %}
<span
class=
"help-inline"
>
{{ form.user.errors|join:", " }}
</span>
{% endif %}
<span
class=
"help-block"
>
{{ form.user.help_text }}
</span>
</div>
</div>
<div
class=
"control-group {% if form.institution.errors %} error {% endif %}"
>
<label
class=
"control-label"
for=
"id_institution"
><b>
{% trans "Institution" %}
</b></label>
<div
class=
"controls"
>
{{ form.institution }}
{% if form.institution.errors %}
<span
class=
"help-inline"
>
{{ form.institution.errors|join:", " }}
</span>
{% endif %}
<span
class=
"help-block"
>
{{ form.institution.help_text }}
</span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"controls"
>
<button
type=
"submit"
id=
"applybutton"
value=
"Apply"
class=
"btn btn-primary"
/>
{% trans "Activate" %}
</button>
</div>
</div>
</form>
</div>
</div>
<!--/span-->
<!--/span-->
</div>
<!--/row-->
</div>
<!--/span-->
</div>
<!--/row-->
<hr>
<footer>
<p>
©
GRNET NOC - GRNET S.A - 2012
</p>
</footer>
</div>
<!--/.fluid-container-->
{% endblock %}
{% block subcontent %}
{% endblock %}
\ No newline at end of file
templates/registration/activation_complete.html
0 → 100644
View file @
60a4dc45
{% extends "base.html" %}
{% load i18n %}
{% block title %}{% trans "Activation Complete" %}{% endblock %}
{% block topmenu %}
<ul
class=
"nav"
>
<li>
<a
href=
"{% url index %}"
>
{% trans "Home" %}
</a>
</li>
<li>
<a
href=
"/faq/{{LANGUAGE_CODE}}/"
>
FAQ
</a>
</li>
<li>
<a
href=
"{% url login %}"
style=
"padding-top: 3px; padding-bottom: 0px;"
>
{% trans "Manage" %}
<img
src=
"/static/img/image_shibboleth_logo_color.png"
style=
"padding: 0px;"
></a>
</li>
</ul>
{% endblock %}
{% block content %}
<div
class=
"container-fluid"
>
<div
class=
"row-fluid"
>
<div
class=
"span2"
>
</div>
<!--/span-->
<div
class=
"span10"
>
<div
class=
"row-fluid"
>
<!--/span-->
<h3>
{% trans "Activation Complete" %}
</h3>
<hr>
{% block subcontent %}
<div
class=
"span10 alert alert-success"
>
{% trans "The user will be notified about his/her account activation" %}
</div>
{% endblock %}
<!--/span-->
</div>
<!--/row-->
</div>
<!--/span-->
</div>
<!--/span-->
<hr>
<footer>
<p>
©
@ GRNET NOC 2012
</p>
</footer>
</div>
<!--/.fluid-container-->
{% endblock %}
\ No newline at end of file
templates/registration/activation_complete.txt
0 → 100644
View file @
60a4dc45
Ο λογαριασμός σας με όνομα χρήστη «{{user.username}}» ενεργοποιήθηκε.
Μπορείτε να χρησιμοποιήσετε την υπηρεσία eduroam management, κάνοντας login στην παρακάτω
διεύθυνση:
http://{{ site.domain }}{% url login %}
---------------------------------------------------------------------------
Your account with username “{{ user.username }}” has been activated.
You may login to eduroam management using the following URL:
http://{{ site.domain }}{% url login %}
templates/registration/activation_complete_subject.txt
0 → 100644
View file @
60a4dc45
Activation complete
\ No newline at end of file
templates/registration/activation_email.txt
0 → 100644
View file @
60a4dc45
Ο/H {{ user.get_full_name }} έκανε αίτηση για νεό λογαριασμό στην υπηρεσία.
Όνομα χρήστη: {{ user.username }}
E-mail: {{ user.email }}
Φορέας: {{institution}}
Για να ενεργοποιήσετε το λογαριασμό και να επιτρέψετε στο χρήστη να
χρησιμοποιήσει την υπηρεσία, επισκεφθείτε τον ακόλουθο σύνδεσμο:
http://{{ site.domain }}{% url activate_account activation_key %}
Ο χρήστης θα ενημερωθεί για την ενεργοποίηση του λογαριασμού του μέσω e-mail.
-----------------------------------------------------------------------------
{{ user.get_full_name }} has registered for a new account.
Username: {{user.username}}
E-mail: {{user.email}}
Φορέας: {{institution}}
To activate the user's account and allow them to access the service, click on
the following link:
http://{{ site.domain }}{% url activate_account activation_key %}
The user will be notified via mail about the account activation
templates/registration/activation_email_subject.txt
0 → 100644
View file @
60a4dc45
Account registered at {{ site.name }}
templates/registration/select_institution.html
View file @
60a4dc45
{% extends "base.html" %}
{% load i18n %}
{% block topmenu %}
<ul
class=
"nav"
>
<li>
<a
href=
"{% url index %}"
>
{% trans "Home" %}
</a>
</li>
<li>
<a
href=
"/faq/{{LANGUAGE_CODE}}/"
>
FAQ
</a>
</li>
<li>
<a
href=
"{% url login %}"
style=
"padding-top: 3px; padding-bottom: 0px;"
>
{% trans "Manage" %}
<img
src=
"/static/img/image_shibboleth_logo_color.png"
style=
"padding: 0px;"
></a>
</li>
</ul>
{% endblock %}
{% block content %}
<div
class=
"container-fluid"
>
...
...
@@ -50,7 +63,6 @@ Select your institution to proceed. Our administrators will activate your accoun
<!--/span-->
</div>
<!--/row-->
</div>
<!--/span-->
</div>
<!--/row-->
<hr>
<footer>
<p>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment