|
3 | 3 | # @Author: Adrien Chardon |
4 | 4 | # @Date: 2014-08-21 18:22:36 |
5 | 5 | # @Last Modified by: Adrien Chardon |
6 | | -# @Last Modified time: 2014-10-28 19:53:32 |
| 6 | +# @Last Modified time: 2014-10-30 22:34:41 |
7 | 7 |
|
8 | 8 | # This file is part of iTeam.org. |
9 | 9 | # Copyright (C) 2014 Adrien Chardon (Nodraak). |
|
29 | 29 | from django.core.urlresolvers import reverse |
30 | 30 | from django.conf import settings |
31 | 31 | from django.contrib.auth.decorators import login_required |
| 32 | +from django.contrib.auth.models import User |
32 | 33 | from django.shortcuts import render, get_object_or_404, redirect |
33 | 34 | from django.template.defaultfilters import slugify |
34 | 35 | from django.utils import timezone |
35 | 36 |
|
| 37 | +from iTeam.member.models import Profile |
36 | 38 | from iTeam.publications.models import Publication |
37 | 39 | from iTeam.publications.forms import PublicationForm |
38 | 40 |
|
@@ -101,6 +103,28 @@ def detail(request, publication_id, publication_slug): |
101 | 103 | raise PermissionDenied |
102 | 104 |
|
103 | 105 |
|
| 106 | +def by_author(request, username): |
| 107 | + user = get_object_or_404(User, username=username) |
| 108 | + profile = get_object_or_404(Profile, user=user) |
| 109 | + |
| 110 | + profileRequest = None |
| 111 | + if request.user.is_authenticated(): |
| 112 | + profileRequest = get_object_or_404(Profile, user=request.user) |
| 113 | + |
| 114 | + publications_all = Publication.objects.all().filter(author=user).order_by('-pub_date') |
| 115 | + publications_list = publications_all.filter(is_draft=False) |
| 116 | + publications_drafts = publications_all.filter(is_draft=True) |
| 117 | + |
| 118 | + c = { |
| 119 | + 'profile_detail': profile, |
| 120 | + 'profile_request': profileRequest, |
| 121 | + 'publications_list': publications_list, |
| 122 | + 'publications_draft_list': publications_drafts, |
| 123 | + } |
| 124 | + |
| 125 | + return render(request, 'publications/by_author.html', c) |
| 126 | + |
| 127 | + |
104 | 128 | @login_required |
105 | 129 | def create(request): |
106 | 130 | profile = request.user.profile # login_required |
|
0 commit comments