3
̜^                 @   s   d Z 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 ddlmZmZmZmZ dd	 Zd
e_dd Zde_G dd dejZG dd dejZG dd dejZG dd dejZejjee ejjee ejjee ejjee dS )z
App Admin Customization
    )settings)admin)messages)helpers)gettext_lazy)CityEmailMessageCountryStatec             C   sJ   |j dd}|dkr$d| jjj }nd|| jjjf }| j|d|  dS )z
    Bulk Activate
    T)	is_active   z1 %s wasz
%s %s werez!%s successfully marked as active.N)updatemodel_metaverbose_nameverbose_name_pluralmessage_user)_modeladmin_requestquerysetrows_updatedmessage_bit r   6/home/hotel/hotelbackend/hotelapplication/app/admin.pymake_as_active   s    r   zMark selected as Activec             C   sJ   |j dd}|dkr$d| jjj }nd|| jjjf }| j|d|  dS )z(
    Deactivate Dropdown on listing
    F)r   r   z1 %s wasz
%s %s werez%%s successfully marked as deactivate.N)r   r   r   r   r   r   )r   r   r   r   r   r   r   r   make_as_disabled   s    r   zMark selected as Deactivatec                   s@   e Zd ZdZeZddgZdgZdgZe	e
gZ fddZ  ZS )AdminCountryz%
    Admin Class for State Model
    namer   c                s    | j }tt| j|}|d= |S )u1  
         Disable actions on a per-request
         by overriding ModelAdmin.get_actions()
         Most of the time you’ll use this method to
         conditionally remove actions from the list
         gathered by the superclass.

         Here we remove delete_selected action from dropdown
         delete_selected)	__class__superr   get_actions)selfrequest_actions)r   r   r   r!   =   s    
zAdminCountry.get_actions)__name__
__module____qualname____doc__r	   modelslist_displaysearch_fieldslist_filterr   r   r%   r!   __classcell__r   r   )r   r   r   1   s   r   c                   sD   e Zd ZdZeZdddgZddgZdgZe	e
gZ fddZ  ZS )
AdminStatez%
    Admin Class for State Model
    r   countryr   c                s    | j }tt| j|}|d= |S )u1  
         Disable actions on a per-request
         by overriding ModelAdmin.get_actions()
         Most of the time you’ll use this method to
         conditionally remove actions from the list
         gathered by the superclass.

         Here we remove delete_selected action from dropdown
         r   )r   r    r/   r!   )r"   r#   r$   r%   )r   r   r   r!   Y   s    
zAdminState.get_actions)r&   r'   r(   r)   r
   r*   r+   r,   r-   r   r   r%   r!   r.   r   r   )r   r   r/   M   s   r/   c                   sD   e Zd ZdZeZdddgZddgZdgZe	e
gZ fddZ  ZS )	AdminCityz$
    Admin Class for City Model
    r   stater   c                s    | j }tt| j|}|d= |S )u1  
         Disable actions on a per-request
         by overriding ModelAdmin.get_actions()
         Most of the time you’ll use this method to
         conditionally remove actions from the list
         gathered by the superclass.

         Here we remove delete_selected action from dropdown
         r   )r   r    r1   r!   )r"   r#   r$   r%   )r   r   r   r!   u   s    
zAdminCity.get_actions)r&   r'   r(   r)   r   r*   r+   r,   r-   r   r   r%   r!   r.   r   r   )r   r   r1   i   s   r1   c               @   s,   e Zd ZdZeZddddddgZdd	 Zd
S )AdminEmailMessagez'
    Admin Class for Email Message
    
from_emailto_emailsubjectsent_status	sent_datecreate_datec             C   s
   | j }dS )z
        Access denied admin user to create new object.
        Remove Add Object button from listing page.
        It gives 403 page if someone tried with direct
        url type.
        F)r   )r"   r#   r$   r   r   r   has_add_permission   s    z$AdminEmailMessage.has_add_permissionN)r&   r'   r(   r)   r   r*   r+   r:   r   r   r   r   r3      s
   
r3   N)r)   django.confr   Zdjango.contribr   r   flash_messagesdjango.contrib.adminr   django.utils.translationr   r$   
app.modelsr   r   r	   r
   r   short_descriptionr   
ModelAdminr   r/   r1   r3   siteregisterr   r   r   r   <module>   s$   