Commit 58da9d495ed3ba47ab10d279d47e69fbefe6711a
- Diff rendering mode:
- inline
- side by side
pm/forum/models.py
(7 / 1)
|   | |||
| 104 | 104 | t = TopicRead(post=topic.last_post, topic=topic, user=get_current_user()) | |
| 105 | 105 | t.save() | |
| 106 | 106 | ||
| 107 | def list_last_topics(nb,private,auth): | ||
| 107 | def list_last_topics(nb, u = None): | ||
| 108 | private = False | ||
| 109 | auth = False | ||
| 110 | if u is not None: | ||
| 111 | priv = u.is_staff | ||
| 112 | auth = u.is_authenticated() | ||
| 113 | |||
| 108 | 114 | topics = Topic.objects.annotate(models.Count('post')) | |
| 109 | 115 | if not private: | |
| 110 | 116 | topics = topics.filter(forum__staff_only = False) |
pm/pages/feeds.py
(20 / 1)
|   | |||
| 2 | 2 | from django.contrib.syndication.feeds import Feed | |
| 3 | 3 | from nouvelle.models import get_latest_news | |
| 4 | 4 | from tutoriel.models import get_latest_tutorials | |
| 5 | from forum.models import list_last_topics | ||
| 5 | 6 | ||
| 6 | 7 | class NewsFeed(Feed): | |
| 7 | 8 | title = "News du Programmeur Moderne" | |
| … | … | ||
| 26 | 26 | def item_pubdate(self, item): | |
| 27 | 27 | return item.up_date | |
| 28 | 28 | ||
| 29 | |||
| 29 | class ForumFeed(Feed): | ||
| 30 | title = "Forum du Programmeur Moderne" | ||
| 31 | link = "/forums/" | ||
| 32 | description = "Flux RSS des derniers messages des forums du Programmeur Moderne" | ||
| 33 | |||
| 34 | def items(self): | ||
| 35 | return list_last_topics(8) | ||
| 36 | |||
| 37 | def item_pubdate(self, item): | ||
| 38 | return item.creation | ||
| 39 | |||
| 40 | def item_title(self, item): | ||
| 41 | return item.sujet | ||
| 42 | |||
| 43 | def item_description(self, item): | ||
| 44 | return item.last_post.texte | ||
| 45 | |||
| 46 | def item_author_name(self, item): | ||
| 47 | return item.last_post.author |
pm/pages/home.py
(1 / 1)
|   | |||
| 14 | 14 | big_tuts = tuts[0:3] | |
| 15 | 15 | small_tuts = tuts[3:] | |
| 16 | 16 | ||
| 17 | last_topics = list_last_topics(6, request.user.is_staff, request.user.is_authenticated()) | ||
| 17 | last_topics = list_last_topics(6, request.user) | ||
| 18 | 18 | ||
| 19 | 19 | return render_to_response('home.html', {'big_news':big_news, 'small_news':small_news, | |
| 20 | 20 | 'big_tuts':big_tuts, 'small_tuts':small_tuts, |
pm/urls.py
(3 / 2)
|   | |||
| 7 | 7 | import django.views.static | |
| 8 | 8 | import captcha.urls | |
| 9 | 9 | ||
| 10 | from pages.feeds import NewsFeed, TutorielsFeed | ||
| 10 | from pages.feeds import NewsFeed, TutorielsFeed, ForumFeed | ||
| 11 | 11 | from settings import pfx | |
| 12 | 12 | import nouvelle.urls, nouvelle.views | |
| 13 | 13 | import tutoriel.urls, tutoriel.views | |
| … | … | ||
| 33 | 33 | ||
| 34 | 34 | feeds = { | |
| 35 | 35 | 'nouvelles': NewsFeed, | |
| 36 | 'tutoriels': TutorielsFeed | ||
| 36 | 'tutoriels': TutorielsFeed, | ||
| 37 | 'forum': ForumFeed | ||
| 37 | 38 | } | |
| 38 | 39 | ||
| 39 | 40 | vote_news = { |
templates/base.html
(1 / 1)
|   | |||
| 61 | 61 | </div> | |
| 62 | 62 | </div> | |
| 63 | 63 | <div id="footer"> | |
| 64 | <p>Hébergé sur <a href="http://awesom.eu">awesom.eu</a> - <a href="http://redmine.awesom.eu/projects/show/progmod">Bug tracker</a> - <a href="http://gitorious.org/pm/pm">Code du site</a> - Flux RSS : <a href="http://progmod.org/flux/nouvelles">News</a> - <a href="http://progmod.org/flux/tutoriels">Tutoriels</a></p> | ||
| 64 | <p>Hébergé sur <a href="http://awesom.eu">awesom.eu</a> - <a href="http://redmine.awesom.eu/projects/show/progmod">Bug tracker</a> - <a href="http://gitorious.org/pm/pm">Code du site</a> - Flux RSS : <a href="http://progmod.org/flux/nouvelles">News</a> - <a href="http://progmod.org/flux/tutoriels">Tutoriels</a> - <a href="http://progmod.org/flux/forum">Forum</a></p> | ||
| 65 | 65 | </div> | |
| 66 | 66 | </div> | |
| 67 | 67 |
templates/home.html
(5 / 3)
|   | |||
| 52 | 52 | ||
| 53 | 53 | <li class="{% cycle 'i' 'p' %}">{{ topic.last_post.author|author_link:"auteur-post|Auteur du dernier message"}}, dans | |
| 54 | 54 | {% if user.is_authenticated %} | |
| 55 | <a href="{{ topic.last_read_post.get_absolute_url }}">{{ topic.sujet }}</a> ({{ topic.post__count }}) | ||
| 55 | <a href="{{ topic.last_read_post.get_absolute_url }}">{{ topic.sujet }}</a> | ||
| 56 | {% with n=topic.post__count %} | ||
| 57 | {% if n > 0 %} | ||
| 58 | ({{ n }} non lu{% if n > 1 %}s{% endif %}){% endif %}{% endwith %} | ||
| 56 | 59 | {% else %} | |
| 57 | <a href="{{ topic.last_post.get_absolute_url }}">{{ topic.sujet }}</a> ({{ topic.post__count }}) | ||
| 60 | <a href="{{ topic.last_post.get_absolute_url }}">{{ topic.sujet }}</a> ({{ topic.post__count }} messages) | ||
| 58 | 61 | {% endif %} | |
| 59 | <span class="date">{% humane_date topic.last_post.creation %}</span></li> | ||
| 60 | 62 | {% empty %} | |
| 61 | 63 | <li>Forum vide</li> | |
| 62 | 64 | {% endfor %} |

