Ñò
[ã0Kc           @   sú   d  d k  Z  d  d k l Z d  d k l Z d  d k l Z d  d k l Z d  d k	 l
 Z
 d  d k l Z d  d k l Z d  d	 k l Z d  d
 k l Z e e d d ƒ Z d e i f d „  ƒ  YZ d e f d „  ƒ  YZ d e i f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   User(   t   CommentManager(   t   generic(   t   ContentType(   t   Site(   t   models(   t   urlresolvers(   t   ugettext_lazy(   t   settingst   COMMENT_MAX_LENGTHi¸  t   BaseCommentAbstractModelc           B   s‡   e  Z d  Z e i e d e d ƒ d d ƒZ e i e d ƒ ƒ Z	 e
 i d d d d	 ƒ Z e i e ƒ Z d
 d d „  ƒ  YZ d „  Z RS(   s]   
    An abstract base class that any custom comment models probably should
    subclass.
    t   verbose_names   content typet   related_names   content_type_set_for_%(class)ss	   object IDt   ct_fieldt   content_typet   fk_fieldt	   object_pkt   Metac           B   s   e  Z e Z RS(    (   t   __name__t
   __module__t   Truet   abstract(    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyR      s   c         C   s   t  i d d |  i |  i f ƒS(   sK   
        Get a URL suitable for redirecting to the content object.
        s   comments-url-redirectt   args(   R   t   reverset   content_type_idR   (   t   self(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt   get_content_object_url!   s    (    (   R   R   t   __doc__R   t
   ForeignKeyR   t   _R   t	   TextFieldR   R   t   GenericForeignKeyt   content_objectR   t   siteR   R   (    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyR
      s   	t   Commentc        
   B   s  e  Z d  Z e i e d e d ƒ d e d e d d ƒZ e i	 e d ƒ d d	 d e ƒZ
 e i e d
 ƒ d e ƒZ e i e d ƒ d e ƒZ e i e d ƒ d e ƒZ e i e d ƒ d d' ƒZ e i e d ƒ d e d e ƒZ e i e d ƒ d e d e d ƒ ƒZ e i e d ƒ d e d e d ƒ ƒZ e ƒ  Z d d( d „  ƒ  YZ d „  Z d „  Z d „  Z  e! e  d e  i ƒZ" d „  Z# d „  Z$ e! e# e$ d d ƒZ% d „  Z& d „  Z' e! e& e' d d  ƒZ( d! „  Z) d" „  Z* e! e) e* d d# ƒZ+ d$ d% „ Z, d& „  Z- RS()   s+   
    A user comment about some object.
    R   t   usert   blankt   nullR   s   %(class)s_commentss   user's namet
   max_lengthi2   s   user's email addresss
   user's URLt   comments   date/time submittedt   defaults
   IP addresss	   is publict	   help_textsI   Uncheck this box to make the comment effectively disappear from the site.s
   is removedst   Check this box if the comment is inappropriate. A "This comment has been removed" message will be displayed instead.R   c           B   s5   e  Z d  Z d Z d g Z e d ƒ Z e d ƒ Z RS(   t   django_commentst   submit_datet   can_moderates   Can moderate commentsR'   t   comments(   s   submit_date(   R,   s   Can moderate comments(   R   R   t   db_tablet   orderingt   permissionsR   R   t   verbose_name_plural(    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyR   H   s
   	c         C   s   d |  i  |  i d  f S(   Ns	   %s: %s...i2   (   t   nameR'   (   R   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt   __unicode__O   s    c         O   sC   |  i  d  j o t i i ƒ  |  _  n t t |  ƒ i | | Ž  d  S(   N(   R+   t   Nonet   datetimet   nowt   superR"   t   save(   R   R   t   kwargs(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyR8   R   s    c         C   s¼   t  |  d ƒ p¥ h |  i d 6|  i d 6|  i d 6|  _ |  i op |  i } | i o | i |  i d <n | i ƒ  o |  i i ƒ  |  i d <q± |  i p | i	 |  i d <q± qµ n |  i S(   sß   
        Get a dictionary that pulls together information about the poster
        safely for both authenticated and non-authenticated comments.

        This dict will have ``name``, ``email``, and ``url`` fields.
        t	   _userinfoR2   t   emailt   url(
   t   hasattrt	   user_namet
   user_emailt   user_urlR:   t   user_idR#   R;   t   get_full_namet   username(   R   t   u(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt   _get_userinfoW   s    


	

t   docc         C   s   |  i  d S(   NR2   (   t   userinfo(   R   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt	   _get_names   s    c         C   s-   |  i  o t t d ƒ ƒ ‚ n | |  _ d  S(   NsP   This comment was posted by an authenticated user and thus the name is read-only.(   RA   t   AttributeErrorR   R>   (   R   t   val(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt	   _set_nameu   s    
s,   The name of the user who posted this commentc         C   s   |  i  d S(   NR;   (   RG   (   R   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt
   _get_email|   s    c         C   s-   |  i  o t t d ƒ ƒ ‚ n | |  _ d  S(   NsQ   This comment was posted by an authenticated user and thus the email is read-only.(   RA   RI   R   R?   (   R   RJ   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt
   _set_email~   s    
s-   The email of the user who posted this commentc         C   s   |  i  d S(   NR<   (   RG   (   R   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt   _get_url…   s    c         C   s   | |  _  d  S(   N(   R@   (   R   RJ   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt   _set_url‡   s    s1   The URL given by the user who posted this comments   #c%(id)sc         C   s   |  i  ƒ  | |  i S(   N(   R   t   __dict__(   R   t   anchor_pattern(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt   get_absolute_url‹   s    c         C   sV   h |  i  p |  i d 6|  i d 6|  i d 6|  i i d 6|  i ƒ  d 6} t d ƒ | S(   sH   
        Return this comment as plain text.  Useful for emails.
        R#   t   dateR'   t   domainR<   sE   Posted by %(user)s at %(date)s

%(comment)s

http://%(domain)s%(url)s(   R#   R2   R+   R'   R!   RT   RR   R   (   R   t   d(    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt   get_as_textŽ   s    

N(    (.   R   R   R   R   R   R    R   R   R#   t	   CharFieldR>   t
   EmailFieldR?   t   URLFieldR@   R   R	   R'   t   DateTimeFieldR4   R+   t   IPAddressFieldt
   ip_addresst   BooleanFieldt	   is_publict   Falset
   is_removedR   t   objectsR   R3   R8   RE   t   propertyRG   RH   RK   R2   RL   RM   R;   RN   RO   R<   RR   RV   (    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyR"   *   s<   !!										t   CommentFlagc           B   sÃ   e  Z d  Z e i e d e d ƒ d d ƒZ e i e d e d ƒ d d ƒZ	 e i
 e d ƒ d d	 d
 e ƒZ e i e d ƒ d d ƒZ d Z d Z d Z d d d „  ƒ  YZ d „  Z d „  Z RS(   sÐ  
    Records a flag on a comment. This is intentionally flexible; right now, a
    flag could be:

        * A "removal suggestion" -- where a user suggests a comment for (potential) removal.

        * A "moderator deletion" -- used when a moderator deletes a comment.

    You can (ab)use this model to add other flags, if needed. However, by
    design users are only allowed to flag a comment with a given flag once;
    if you want rating look elsewhere.
    R   R#   R   t   comment_flagsR'   t   flagst   flagR&   i   t   db_indexRS   R(   s   removal suggestions   moderator deletions   moderator approvalR   c           B   s/   e  Z d  Z d g Z e d ƒ Z e d ƒ Z RS(   t   django_comment_flagsR#   R'   Rf   s   comment flags   comment flags(   s   users   comments   flag(   R   R   R.   t   unique_togetherR   R   R1   (    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyR   ²   s   	c         C   s   d |  i  |  i |  i i f S(   Ns   %s flag of comment ID %s by %s(   Rf   t
   comment_idR#   RC   (   R   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyR3   ¸   s    c         O   sC   |  i  d  j o t i i ƒ  |  _  n t t |  ƒ i | | Ž  d  S(   N(   t	   flag_dateR4   R5   R6   R7   Rc   R8   (   R   R   R9   (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyR8   ¼   s    N(    (   R   R   R   R   R   R    R   R#   R"   R'   RW   R   Rf   RZ   R4   Rk   t   SUGGEST_REMOVALt   MODERATOR_DELETIONt   MODERATOR_APPROVALR   R3   R8   (    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyRc   ›   s   !!!	(   R5   t   django.contrib.auth.modelsR    t    django.contrib.comments.managersR   t   django.contrib.contenttypesR   t"   django.contrib.contenttypes.modelsR   t   django.contrib.sites.modelsR   t	   django.dbR   t   django.coreR   t   django.utils.translationR   R   t   django.confR   t   getattrR	   t   ModelR
   R"   Rc   (    (    (    sH   /usr/local/lib/python2.6/dist-packages/django/contrib/comments/models.pyt   <module>   s   q