Minor update.
[cas.git] / src / emails / views.py
1 from django.contrib.auth.decorators import login_required, permission_required
2 from django.contrib.auth.models import User
3 from django.shortcuts import render, get_object_or_404
4 from .models import Alias
5 from . import BASE_DOMAINS
6
7
8 @login_required
9 def my_aliases(request, user=None):
10     user = user or request.user  
11     return render(request, 'emails/my_aliases.html', {
12         'user': user,
13         'base': ['{}@{}'.format(user.username, dom) for dom in BASE_DOMAINS],
14         'from_me': Alias.get_from_user(user),
15         })
16
17
18 @permission_required('emails.can_add_alias')
19 def user_aliases(request, username):
20     user = get_object_or_404(User, username=username)
21     return my_aliases(request, user=user)
22