ó
A()Qc           @@  sT  d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d  d l m	 Z	 m
 Z
 d  d l m Z d  d l m Z m Z d  d l m Z m Z d  d	 l m Z e e	 d d
    Z e e
 d  d d    Z e e
 d  d d    Z d   Z d   Z d   Z e d d d d  Z e d d d d  Z e d d d d  Z d S(   i    (   t   absolute_import(   t   template(   t   settings(   t   comments(   t   login_requiredt   permission_required(   t   signals(   t   next_redirectt   confirmation_view(   t   get_object_or_404t   render_to_response(   t   csrf_protectc         C@  s   t  t j   d | d t j } |  j d k r\ t |  |  t |  d | pO d d | j St	 d i | d 6| d	 6t
 j |    Sd
 S(   sū   
    Flags a comment. Confirmation on GET, action on POST.

    Templates: :template:`comments/flag.html`,
    Context:
        comment
            the flagged `comments.comment` object
    t   pkt   site__pkt   POSTt   fallbacks   comments-flag-donet   cs   comments/flag.htmlt   commentt   nextN(   R	   R   t	   get_modelR   t   SITE_IDt   methodt   perform_flagR   R   R
   R   t   RequestContext(   t   requestt
   comment_idR   R   (    (    sA   ../Django//lib/python/django/contrib/comments/views/moderation.pyt   flag   s    !
s   comments.can_moderatec         C@  s   t  t j   d | d t j } |  j d k r\ t |  |  t |  d | pO d d | j St	 d i | d 6| d	 6t
 j |    Sd
 S(   sũ   
    Deletes a comment. Confirmation on GET, action on POST. Requires the "can
    moderate comments" permission.

    Templates: :template:`comments/delete.html`,
    Context:
        comment
            the flagged `comments.comment` object
    R   R   R   R   s   comments-delete-doneR   s   comments/delete.htmlR   R   N(   R	   R   R   R   R   R   t   perform_deleteR   R   R
   R   R   (   R   R   R   R   (    (    sA   ../Django//lib/python/django/contrib/comments/views/moderation.pyt   delete'   s    !
c         C@  s   t  t j   d | d t j } |  j d k r\ t |  |  t |  d | pO d d | j St	 d i | d 6| d	 6t
 j |    Sd
 S(   s*  
    Approve a comment (that is, mark it as public and non-removed). Confirmation
    on GET, action on POST. Requires the "can moderate comments" permission.

    Templates: :template:`comments/approve.html`,
    Context:
        comment
            the `comments.comment` object for approval
    R   R   R   R   s   comments-approve-doneR   s   comments/approve.htmlR   R   N(   R	   R   R   R   R   R   t   perform_approveR   R   R
   R   R   (   R   R   R   R   (    (    sA   ../Django//lib/python/django/contrib/comments/views/moderation.pyt   approveC   s    !
c         C@  sk   t  j j j j d | d |  j d t  j j j  \ } } t j j	 d | j
 d | d | d | d |   d S(   sD   
    Actually perform the flagging of a comment from a request.
    R   t   userR   t   sendert   createdR   N(   R   t   modelst   CommentFlagt   objectst   get_or_createR   t   SUGGEST_REMOVALR   t   comment_was_flaggedt   sendt	   __class__(   R   R   R   R!   (    (    sA   ../Django//lib/python/django/contrib/comments/views/moderation.pyR   c   s    		c         C@  s~   t  j j j j d | d |  j d t  j j j  \ } } t | _ | j	   t
 j j d | j d | d | d | d |   d  S(   NR   R   R   R    R!   R   (   R   R"   R#   R$   R%   R   t   MODERATOR_DELETIONt   Truet
   is_removedt   saveR   R'   R(   R)   (   R   R   R   R!   (    (    sA   ../Django//lib/python/django/contrib/comments/views/moderation.pyR   t   s    		
	c         C@  s   t  j j j j d | d |  j d t  j j j  \ } } t | _ t	 | _
 | j   t j j d | j d | d | d | d |   d  S(   NR   R   R   R    R!   R   (   R   R"   R#   R$   R%   R   t   MODERATOR_APPROVALt   FalseR,   R+   t	   is_publicR-   R   R'   R(   R)   (   R   R   R   R!   (    (    sA   ../Django//lib/python/django/contrib/comments/views/moderation.pyR      s    			
	R   s   comments/flagged.htmlt   docs.   Displays a "comment was flagged" success page.s   comments/deleted.htmls.   Displays a "comment was deleted" success page.s   comments/approved.htmls/   Displays a "comment was approved" success page.N(   t
   __future__R    t   djangoR   t   django.confR   t   django.contribR   t   django.contrib.auth.decoratorsR   R   t   django.contrib.commentsR   t#   django.contrib.comments.views.utilsR   R   t   django.shortcutsR	   R
   t   django.views.decorators.csrfR   t   NoneR   R   R   R   R   R   t	   flag_donet   delete_donet   approve_done(    (    (    sA   ../Django//lib/python/django/contrib/comments/views/moderation.pyt   <module>   s:   							