Commit 58da9d495ed3ba47ab10d279d47e69fbefe6711a

  • avatar
  • xarch
  • Thu May 12 18:23:03 CEST 2011
Flux RSS forum, compteur lu/non lu de la page d'accueil amélioré
  
104104 t = TopicRead(post=topic.last_post, topic=topic, user=get_current_user())
105105 t.save()
106106
107def list_last_topics(nb,private,auth):
107def 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
108114 topics = Topic.objects.annotate(models.Count('post'))
109115 if not private:
110116 topics = topics.filter(forum__staff_only = False)
  
22from django.contrib.syndication.feeds import Feed
33from nouvelle.models import get_latest_news
44from tutoriel.models import get_latest_tutorials
5from forum.models import list_last_topics
56
67class NewsFeed(Feed):
78 title = "News du Programmeur Moderne"
2626 def item_pubdate(self, item):
2727 return item.up_date
2828
29
29class 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
  
1414 big_tuts = tuts[0:3]
1515 small_tuts = tuts[3:]
1616
17 last_topics = list_last_topics(6, request.user.is_staff, request.user.is_authenticated())
17 last_topics = list_last_topics(6, request.user)
1818
1919 return render_to_response('home.html', {'big_news':big_news, 'small_news':small_news,
2020 'big_tuts':big_tuts, 'small_tuts':small_tuts,
pm/urls.py
(3 / 2)
  
77import django.views.static
88import captcha.urls
99
10from pages.feeds import NewsFeed, TutorielsFeed
10from pages.feeds import NewsFeed, TutorielsFeed, ForumFeed
1111from settings import pfx
1212import nouvelle.urls, nouvelle.views
1313import tutoriel.urls, tutoriel.views
3333
3434feeds = {
3535 'nouvelles': NewsFeed,
36 'tutoriels': TutorielsFeed
36 'tutoriels': TutorielsFeed,
37 'forum': ForumFeed
3738}
3839
3940vote_news = {
  
6161 </div>
6262 </div>
6363 <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>
6565 </div>
6666 </div>
6767
  
5252
5353<li class="{% cycle 'i' 'p' %}">{{ topic.last_post.author|author_link:"auteur-post|Auteur du dernier message"}}, dans
5454 {% 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 %}
5659 {% 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)
5861 {% endif %}
59 <span class="date">{% humane_date topic.last_post.creation %}</span></li>
6062{% empty %}
6163<li>Forum vide</li>
6264{% endfor %}