1234567891011121314151617181920212223242526 |
- from django.contrib.auth.decorators import login_required
- from django.core.exceptions import PermissionDenied
- from django.shortcuts import render, get_object_or_404
- from django.contrib.auth.models import User
- from .models import Corporation
- @login_required
- def user(request):
- return render(request, 'adhesions/user.html', {
- 'adherent': request.user,
- 'adhesion': request.user.profile.adhesion,
- })
- @login_required
- def corporation(request, pk):
- corporation = get_object_or_404(Corporation, pk=pk)
- try:
- corporation.members.get(pk=request.user.pk)
- except User.DoesNotExist:
- raise PermissionDenied
- return render(request, 'adhesions/corporation.html', {
- 'adherent': corporation,
- 'adhesion': corporation.adhesion,
- })
|