fnp
/
cas.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
some tests, and docker fix
[cas.git]
/
src
/
emails
/
views.py
diff --git
a/src/emails/views.py
b/src/emails/views.py
index
16fa837
..
dc89aaa
100644
(file)
--- a/
src/emails/views.py
+++ b/
src/emails/views.py
@@
-1,13
+1,22
@@
-from django.contrib.auth.decorators import login_required
-from django.shortcuts import render
+from django.contrib.auth.decorators import login_required, permission_required
+from django.contrib.auth.models import User
+from django.shortcuts import render, get_object_or_404
from .models import Alias
from . import BASE_DOMAINS
@login_required
from .models import Alias
from . import BASE_DOMAINS
@login_required
-def my_aliases(request):
+def my_aliases(request, user=None):
+ user = user or request.user
return render(request, 'emails/my_aliases.html', {
return render(request, 'emails/my_aliases.html', {
- '
base': ['{}@{}'.format(request.user.username, dom) for dom in BASE_DOMAINS]
,
- '
to_me': Alias.get_to_user(request.user)
,
- 'from_me': Alias.get_from_user(
request.
user),
+ '
user': user
,
+ '
base': ['{}@{}'.format(user.username, dom) for dom in BASE_DOMAINS]
,
+ 'from_me': Alias.get_from_user(user),
})
})
+
+
+@permission_required('emails.can_add_alias')
+def user_aliases(request, username):
+ user = get_object_or_404(User, username=username)
+ return my_aliases(request, user=user)
+