Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TIC-Desk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Teckids
TIC-Desk
Commits
45354bc9
Verified
Commit
45354bc9
authored
7 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add mail add form.
parent
60d5e171
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ticdesk_account/forms.py
+18
-0
18 additions, 0 deletions
ticdesk_account/forms.py
ticdesk_account/templates/ticdesk_account/manage_mail.html
+34
-0
34 additions, 0 deletions
ticdesk_account/templates/ticdesk_account/manage_mail.html
ticdesk_account/views.py
+54
-1
54 additions, 1 deletion
ticdesk_account/views.py
with
106 additions
and
1 deletion
ticdesk_account/forms.py
+
18
−
0
View file @
45354bc9
...
@@ -19,6 +19,8 @@ NEWSLETTER_CHOICES = {
...
@@ -19,6 +19,8 @@ NEWSLETTER_CHOICES = {
UID_REGEX
=
r
'
^[a-z][a-z0-9]{1,19}$
'
UID_REGEX
=
r
'
^[a-z][a-z0-9]{1,19}$
'
UID_MESSAGE
=
_
(
'
Der Benutzername darf nur aus Kleinbuchstaben und Zahlen bestehen und muss mit einem Buchstaben beginnen!
'
)
UID_MESSAGE
=
_
(
'
Der Benutzername darf nur aus Kleinbuchstaben und Zahlen bestehen und muss mit einem Buchstaben beginnen!
'
)
MAIL_DOMAINS
=
[
'
bessermailer.de
'
,
'
kinder.email
'
,
'
mag-kekse.de
'
,
'
mag-roboter.de
'
]
def
is_username_free
(
uid
):
def
is_username_free
(
uid
):
# Sanity check the uid again to not inject unknown stuff
# Sanity check the uid again to not inject unknown stuff
if
not
re
.
match
(
UID_REGEX
,
uid
):
if
not
re
.
match
(
UID_REGEX
,
uid
):
...
@@ -41,6 +43,9 @@ def is_date_min_years_ago(min_years):
...
@@ -41,6 +43,9 @@ def is_date_min_years_ago(min_years):
raise
forms
.
ValidationError
(
_
(
'
Du musst mindestens %d Jahre alt sein! Hast du vielleicht dein Geburtsdatum falsch angegeben?
'
)
%
min_years
)
raise
forms
.
ValidationError
(
_
(
'
Du musst mindestens %d Jahre alt sein! Hast du vielleicht dein Geburtsdatum falsch angegeben?
'
)
%
min_years
)
return
_the_validator
return
_the_validator
def
is_mail_taken
(
mail
):
return
bool
(
TeckidsPerson
.
objects
.
filter
(
mail_addresses__contains
=
mail
))
class
LoginForm
(
forms
.
Form
):
class
LoginForm
(
forms
.
Form
):
uid
=
forms
.
CharField
(
label
=
_
(
'
Benutzername
'
),
max_length
=
20
)
uid
=
forms
.
CharField
(
label
=
_
(
'
Benutzername
'
),
max_length
=
20
)
password
=
forms
.
CharField
(
label
=
_
(
'
Passwort
'
),
widget
=
forms
.
widgets
.
PasswordInput
)
password
=
forms
.
CharField
(
label
=
_
(
'
Passwort
'
),
widget
=
forms
.
widgets
.
PasswordInput
)
...
@@ -92,3 +97,16 @@ class RegisterForm(forms.Form):
...
@@ -92,3 +97,16 @@ class RegisterForm(forms.Form):
self
.
add_error
(
'
password_repeat
'
,
_
(
'
Passwörter stimmen nicht überein!
'
))
self
.
add_error
(
'
password_repeat
'
,
_
(
'
Passwörter stimmen nicht überein!
'
))
super
(
RegisterForm
,
self
).
clean
()
super
(
RegisterForm
,
self
).
clean
()
class
MailAddForm
(
forms
.
Form
):
local
=
forms
.
CharField
(
label
=
_
(
'
Lokaler Teil (vor dem @-Zeichen)
'
))
domain
=
forms
.
ChoiceField
(
label
=
_
(
'
Domain (nach dem @-Zeichen)
'
),
choices
=
MAIL_DOMAINS
)
def
clean
(
self
):
# Ensure mail address is not taken
local
=
self
.
cleaned_data
.
get
(
'
local
'
)
domain
=
self
.
cleaned_data
.
get
(
'
domain
'
)
if
is_mail_taken
(
'
%s@%s
'
%
(
local
,
domain
)):
self
.
add_error
(
'
local
'
,
_
(
'
Diese E-Mail-Adresse ist bereits belegt!
'
))
super
(
MailAddForm
,
self
).
clean
()
This diff is collapsed.
Click to expand it.
ticdesk_account/templates/ticdesk_account/manage_mail.html
0 → 100644
+
34
−
0
View file @
45354bc9
{% extends "ticdesk/base.html" %}
{% load bootstrap3 i18n %}
{% block inner_content %}
<h1>
{% blocktrans %}E-Mail-Adressen verwalten{% endblocktrans %}
</h1>
<h2>
{% blocktrans %}Neue E-Mail-Adresse anlegen{% endblocktrans %}
</h2>
{% if error %}
<div
class=
"alert alert-danger"
role=
"alert"
>
<p><strong>
{% blocktrans %}Fehler{% endblocktrans %}
</strong></p>
<p>
{{ error }}
</p>
</div>
{% endif %}
{% if success %}
<div
class=
"alert alert-success"
role=
"alert"
>
<p><strong>
{% blocktrans %}Erfolg{% endblocktrans %}
</strong></p>
<p>
{% blocktrans %}
Die E-Mail-Adresse wurde erfolgreich hinzugefügt.
{% endblocktrans %}
</p>
</div>
{% endif %}
<form
method=
"post"
>
{% csrf_token %}
{% bootstrap_form mail_add_form %}
<input
type=
"submit"
value=
"{% blocktrans %}E-Mail-Adresse hinzufügen{% endblocktrans %}"
/>
</form>
{% endblock %}
This diff is collapsed.
Click to expand it.
ticdesk_account/views.py
+
54
−
1
View file @
45354bc9
...
@@ -6,7 +6,7 @@ from django.utils.translation import ugettext as _
...
@@ -6,7 +6,7 @@ from django.utils.translation import ugettext as _
from
pam
import
pam
from
pam
import
pam
import
pexpect
import
pexpect
from
.forms
import
ChPwForm
,
LoginForm
,
RegisterForm
from
.forms
import
ChPwForm
,
LoginForm
,
MailAddForm
,
RegisterForm
from
.models
import
TeckidsGroup
,
TeckidsPerson
from
.models
import
TeckidsGroup
,
TeckidsPerson
def
login
(
request
):
def
login
(
request
):
...
@@ -135,3 +135,56 @@ dein Teckids-Team
...
@@ -135,3 +135,56 @@ dein Teckids-Team
context
[
'
register_form
'
]
=
register_form
context
[
'
register_form
'
]
=
register_form
return
render
(
request
,
'
ticdesk_account/register.html
'
,
context
)
return
render
(
request
,
'
ticdesk_account/register.html
'
,
context
)
def
manage_mail
(
request
):
context
=
{}
mail_add_form
=
MailAddForm
()
# Get current user person
person
=
TeckidsPerson
.
objects
.
get
(
uid
=
request
.
user
.
username
)
if
request
.
method
==
'
POST
'
:
mail_add_form
=
MailAddForm
(
request
.
POST
)
if
mail_add_form
.
is_valid
():
# Assemble new mail address
local
=
mail_add_form
.
cleaned_data
[
'
local
'
]
domain
=
mail_add_form
.
cleaned_data
[
'
domain
'
]
mail
=
'
%s@%s
'
%
(
local
,
domain
)
# Add new address to person
person
.
mail_addresses
.
append
(
mail
)
person
.
save
()
# E-mail user and admins
message
=
EmailMessage
()
message
.
reply_to
=
[
'
root@teckids.org
'
]
message
.
to
=
[
mail
]
if
person
.
mail
and
person
.
mail
!=
mail
:
message
.
to
.
append
(
person
.
mail
)
message
.
cc
=
[
'
root@teckids.org
'
]
if
person
.
mail
and
person
.
mail
!=
mail
:
message
.
cc
.
append
(
person
.
mail
)
message
.
subject
=
_
(
'
E-Mail-Addresse %s angelegt
'
)
%
mail
message
.
extra_headers
=
{
'
X-OTRS-CustomerUser
'
:
person
.
uid
}
message
.
body
=
_
(
"""
Hallo %s,
deine neue E-Mail-Addresse %s wurde angelgt.
Auf unserer Website findest du immer alle Informationen, um deine
E-Mails abzurufen.
Bei Fragen oder Problemen schreibe bitte eine E-Mail an
verein@teckids.org.
Viel Spaß,
dein Teckids-Team
"""
)
%
(
person
.
given_name
,
mail
))
message
.
send
()
context
[
'
success
'
]
=
True
context
[
'
mail_add_form
'
]
=
mail_add_form
return
render
(
request
,
'
ticdesk_account/manage_mail.html
'
,
context
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment