# Path: dinette/views.py
# class LatestTopicsByCategory(Feed):
#     title_template = 'dinette/feeds/title.html'
#     description_template = 'dinette/feeds/description.html'
# 
#     def get_object(self, request, whichcategory):
#         mlogger.debug("Feed for category %s " % whichcategory)
#         return get_object_or_404(Category, slug=whichcategory)
# 
#     def title(self, obj):
#         return "Latest topics in category %s" % obj.name
# 
#     def link(self, obj):
#         return  settings.SITE_URL
# 
#     def items(self, obj):
#         return obj.ftopics_set.all()[:10]
# 
#     #construct these links by means of reverse lookup  by
#     #using permalink decorator
#     def item_link(self,obj):
#         return  obj.get_absolute_url()
# 
#     def item_pubdate(self,obj):
#         return obj.created_on
# 
# class LatestRepliesOfTopic(Feed):
#     title_template = 'dinette/feeds/title.html'
#     description_template = 'dinette/feeds/description.html'
# 
#     def get_object(self, request, whichtopic):
#         mlogger.debug("Feed for category %s " % whichtopic)
#         return get_object_or_404(Ftopics, slug=whichtopic)
# 
#     def title(self, obj):
#         return "Latest replies in topic %s" % obj.subject
# 
#     def link(self, obj):
#         return  settings.SITE_URL
# 
#     def items(self, obj):
#         list = []
#         list.insert(0,obj)
#         for obj in obj.reply_set.all()[:10] :
#             list.append(obj)
#         return list
# 
#      #construct these links by means of reverse lookup  by
#      #using permalink decorator
#     def item_link(self,obj):
#         return  obj.get_absolute_url()
# 
#     def item_pubdate(self,obj):
#         return obj.created_on


from django.conf.urls import *
from dinette.views import LatestTopicsByCategory,LatestRepliesOfTopic
    url(r'^users/(?P<slug>[\w-]+)$', 'user_profile', name='dinette_user_profile'),

    # subscribe to digest
    url(r'^digest/subscribe/$', 'subscribeDigest', name='dinette_subscribe_to_digest'),
    url(r'^digest/unsubscribe/$', 'unsubscribeDigest', name='dinette_unsubscribe_from_digest'),

    url(r'^(?P<categoryslug>[\w-]+)/$','category_details', name='dinette_index'),
    url(r'^(?P<categoryslug>[\w-]+)/page(?P<pageno>\d+)/$','category_details', name='dinette_index2'),
    url(r'^post/topic/$','postTopic', name='dinette_posttopic'),
    url(r'^post/reply/$','postReply', name='dinette_postreply'),
    url(r'^(?P<categoryslug>[\w-]+)/(?P<topic_slug>[\w-]+)/$','topic_detail', name='dinette_topic_detail'),
    url(r'^(?P<categoryslug>[\w-]+)/(?P<topic_slug>[\w-]+)/page(?P<pageno>\d+)/$','topic_detail', name='dinette_reply_detail_paged'),

    #moderation views - Hence dont bother with SEF urls
    url(r'^moderate/topic/(?P<topic_id>\d+)/close/$','moderate_topic', {'action':'close'}, name='dinette_moderate_close'),
    url(r'^moderate/topic/(?P<topic_id>\d+)/stickyfy/$','moderate_topic', {'action':'sticky'}, name='dinette_moderate_sticky'),
    url(r'^moderate/topic/(?P<topic_id>\d+)/annoucement/$','moderate_topic', {'action':'announce'}, name='dinette_moderate_announce'),
    url(r'^moderate/topic/(?P<topic_id>\d+)/hide/$','moderate_topic', {'action':'hide'}, name='dinette_moderate_hide'),

    # post actions, permitted to OP and mods
    url(r'^delete/reply/(?P<reply_id>\d+)$','deleteReply', name='dinette_deletereply'),
    url(r'^edit/reply/(?P<reply_id>\d+)$','editReply', name='dinette_editreply'),

    # subscribe to topic
    url(r'^subscribe/topic/(?P<topic_id>\d+)', 'subscribeTopic', name='dinette_subscribe_to_topic'),
    url(r'^unsubscribe/topic/(?P<topic_id>\d+)', 'unsubscribeTopic', name='dinette_unsubscribe_from_topic'),
)


urlpatterns += patterns('',

# Path: dinette/views.py
# class LatestTopicsByCategory(Feed):
#     title_template = 'dinette/feeds/title.html'
#     description_template = 'dinette/feeds/description.html'
# 
#     def get_object(self, request, whichcategory):
#         mlogger.debug("Feed for category %s " % whichcategory)
#         return get_object_or_404(Category, slug=whichcategory)
# 
#     def title(self, obj):
#         return "Latest topics in category %s" % obj.name
# 
#     def link(self, obj):
#         return  settings.SITE_URL
# 
#     def items(self, obj):
#         return obj.ftopics_set.all()[:10]
# 
#     #construct these links by means of reverse lookup  by
#     #using permalink decorator
#     def item_link(self,obj):
#         return  obj.get_absolute_url()
# 
#     def item_pubdate(self,obj):
#         return obj.created_on
# 
# class LatestRepliesOfTopic(Feed):
#     title_template = 'dinette/feeds/title.html'
#     description_template = 'dinette/feeds/description.html'
# 
#     def get_object(self, request, whichtopic):
#         mlogger.debug("Feed for category %s " % whichtopic)
#         return get_object_or_404(Ftopics, slug=whichtopic)
# 
#     def title(self, obj):
#         return "Latest replies in topic %s" % obj.subject
# 
#     def link(self, obj):
#         return  settings.SITE_URL
# 
#     def items(self, obj):
#         list = []
#         list.insert(0,obj)
#         for obj in obj.reply_set.all()[:10] :
#             list.append(obj)
#         return list
# 
#      #construct these links by means of reverse lookup  by
#      #using permalink decorator
#     def item_link(self,obj):
#         return  obj.get_absolute_url()
# 
#     def item_pubdate(self,obj):
#         return obj.created_on


# Path: dinette/urls.py
from django.conf.urls import *
from dinette.views import LatestTopicsByCategory,LatestRepliesOfTopic

    url(r'^users/(?P<slug>[\w-]+)$', 'user_profile', name='dinette_user_profile'),

    # subscribe to digest
    url(r'^digest/subscribe/$', 'subscribeDigest', name='dinette_subscribe_to_digest'),
    url(r'^digest/unsubscribe/$', 'unsubscribeDigest', name='dinette_unsubscribe_from_digest'),

    url(r'^(?P<categoryslug>[\w-]+)/$','category_details', name='dinette_index'),
    url(r'^(?P<categoryslug>[\w-]+)/page(?P<pageno>\d+)/$','category_details', name='dinette_index2'),
    url(r'^post/topic/$','postTopic', name='dinette_posttopic'),
    url(r'^post/reply/$','postReply', name='dinette_postreply'),
    url(r'^(?P<categoryslug>[\w-]+)/(?P<topic_slug>[\w-]+)/$','topic_detail', name='dinette_topic_detail'),
    url(r'^(?P<categoryslug>[\w-]+)/(?P<topic_slug>[\w-]+)/page(?P<pageno>\d+)/$','topic_detail', name='dinette_reply_detail_paged'),

    #moderation views - Hence dont bother with SEF urls
    url(r'^moderate/topic/(?P<topic_id>\d+)/close/$','moderate_topic', {'action':'close'}, name='dinette_moderate_close'),
    url(r'^moderate/topic/(?P<topic_id>\d+)/stickyfy/$','moderate_topic', {'action':'sticky'}, name='dinette_moderate_sticky'),
    url(r'^moderate/topic/(?P<topic_id>\d+)/annoucement/$','moderate_topic', {'action':'announce'}, name='dinette_moderate_announce'),
    url(r'^moderate/topic/(?P<topic_id>\d+)/hide/$','moderate_topic', {'action':'hide'}, name='dinette_moderate_hide'),

    # post actions, permitted to OP and mods
    url(r'^delete/reply/(?P<reply_id>\d+)$','deleteReply', name='dinette_deletereply'),
    url(r'^edit/reply/(?P<reply_id>\d+)$','editReply', name='dinette_editreply'),

    # subscribe to topic
    url(r'^subscribe/topic/(?P<topic_id>\d+)', 'subscribeTopic', name='dinette_subscribe_to_topic'),
    url(r'^unsubscribe/topic/(?P<topic_id>\d+)', 'unsubscribeTopic', name='dinette_unsubscribe_from_topic'),
)


urlpatterns += patterns('',

    url(r'^feeds/category/(?P<whichcategory>[\w/-]+)/$', LatestTopicsByCategory(), name='dinette_feed_url'),