
    ]j"                     b    d 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Z G d d	e      Zy
)z
set_fake_emails.py

    Give all users a new email account. Useful for testing in a
    development environment. As such, this command is only available when
    setting.DEBUG is True.

    )List)settings)get_user_model)BaseCommandCommandError)signalcommandz%(username)s@example.comc                   P     e Zd ZU dedZg Zee   ed<    fdZ	e
d        Z xZS )CommandzEDEBUG only: give all users a new email based on their account data ("zG" by default). Possible parameters are: username, first_name, last_namerequires_system_checksc                 Z   t         |   |       |j                  ddt        d       |j                  ddddd	d
       |j                  ddddd	d       |j                  ddd d       |j                  ddd d       |j                  ddd d       |j                  ddd d       y )Nz--emaildefault_emailz!Use this as the new email format.)destdefaulthelpz-az
--no-admin
store_trueno_adminFz$Do not change administrator accounts)actionr   r   r   z-sz
--no-staffno_staffzDo not change staff accountsz	--includeinclude_regexpz'Include usernames matching this regexp.z	--excludeexclude_regexpz'Exclude usernames matching this regexp.z--include-groupsinclude_groupszMInclude users matching this group. (use comma seperation for multiple groups)z--exclude-groupsexclude_groupszMExclude users matching this group. (use comma seperation for multiple groups))superadd_argumentsadd_argumentDEFAULT_FAKE_EMAIL)selfparser	__class__s     _/root/env/lib/python3.12/site-packages/django_extensions/management/commands/set_fake_emails.pyr   zCommand.add_arguments   s    f%O5G4 	 	
 	,|* F 	 	
 	,|* > 	 	
 	.: 	 	
 	.: 	 	
 	%5t` 	 	
 	%5t` 	 	
    c                 r   t         j                  st        d      ddlm} |d   }|d   }|d   }|d   }|d   }|d	   }	|d
   }
t               }|j                  j                         }|	r|j                  d      }|
r|j                  d      }|rN|j                  j                  |j                  d            }|r|j                  |      }nt        d|z        |rN|j                  j                  |j                  d            }|r|j                  |      }nt        d|z        |r|j                  |      }|r|j                  |      }|D ]>  }||j                  |j                  |j                  dz  |_        |j                          @ t!        d|j#                         z         y )NzOnly available in debug moder   )Groupr   r   r   r   r   r   r   T)is_superuser)is_staff,)name__in)
groups__inzNo groups matches filter: %s)username__regex)username
first_name	last_namezChanged %d emails)r   DEBUGr   django.contrib.auth.modelsr#   r   objectsallexcludefiltersplitr*   r+   r,   emailsaveprintcount)r   argsoptionsr#   r4   r   r   r   r   r   r   Userusersgroupsusers                  r    handlezCommand.handle9   s   ~~=>>4( !12 !12 !12 !12:&:&  "MMtM4EMM4M0E]]))>3G3G3L)MF8"#AN#RSS]]))>3G3G3L)MF7"#AN#RSSMM.MAELLL@E 	Ddmm04/3~~"? ?DJ IIK		
 	!EKKM12r!   )__name__
__module____qualname__r   r   r   r   str__annotations__r   r   r>   __classcell__)r   s   @r    r
   r
      s:     dv  yD(*DI*
> (3 (3r!   r
   N)__doc__typingr   django.confr   django.contrib.authr   django.core.management.baser   r   "django_extensions.management.utilsr   r   r
    r!   r    <module>rL      s/       . A </ L3k L3r!   