o
    ¦4^hÛ  ã                   @   sD   d dl Z d dlmZ d dlmZmZ d dlmZ G dd„ deƒZdS )é    N)ÚBaseCommand)ÚCourseÚ	HostelFee)ÚCollegec                   @   s   e Zd ZdZdd„ ZdS )ÚCommandzJUpdates hostel fees for all courses in Roorkee College of Business Studiesc              	   O   sÈ  | j  | j d¡¡ ztjjdd}| j  | j d|j› d|j› d¡¡ W n tj	y;   | j  | j 
d¡¡ Y d S w |jj ¡ }| j  | j d| ¡ › d	¡¡ | ¡ sb| j  | j d
¡¡ d S g }|D ].}| j  d|j› d|j› ¡ d|jv r”|j d¡d  d¡}| |¡ | j  d|› ¡ qf| j  | j dt|ƒ› d|› ¡¡ |sµ| j  | j d¡¡ d S tjj|d}| j  | j d| ¡ › d¡¡ | ¡ sÜ| j  | j d¡¡ d S | j  | j d| ¡ › d¡¡ d}	d}
|D ]9}tjj|dddddœd\}}|r|
d7 }
| j  | j d|j› ¡¡ qò|	d7 }	| j  | j d |j› ¡¡ qò| j  | j d!¡¡ | j  | j d"|
› d#¡¡ | j  | j d$|	› d#¡¡ | j  | j d%|
|	 › d&¡¡ d S )'Nz;Starting to update hostel fees for Business Studies coursesé   )ÚidzFound college: z (ID: ú)z-Business Studies college with ID 3 not found.zFound z programs for this collegez#No programs found for this college.z	Program: z
 -> Link: z	/courses/éÿÿÿÿú/z  Extracted slug: z course slugs: z(No valid course links found in programs.)Úslug__inz matching courses in databasez"No courses found for this college.z courses to updater   u	   â‚¹80,000u	   â‚¹20,000u	   â‚¹15,000z¹Hostel fees include accommodation, meals, laundry, and basic amenities. AC rooms are available with additional charges. Security deposit is refundable at the time of leaving the hostel.)Úfee_per_yearÚac_room_additionalÚsecurity_depositÚnotes)ÚcourseÚdefaultsé   zCreated hostel fee for: zUpdated hostel fee for: zHostel fee update complete!z	Created: z hostel feesz	Updated: zTotal processed: z courses)ÚstdoutÚwriteÚstyleÚSUCCESSr   ÚobjectsÚgetÚnamer   ÚDoesNotExistÚERRORÚprograms_sectionÚprogramsÚallÚcountÚexistsÚWARNINGÚlinkÚsplitÚrstripÚappendÚlenr   Úfilterr   Úupdate_or_createÚtitle)ÚselfÚargsÚoptionsÚbusiness_colleger   Úcourse_slugsÚprogramÚslugÚcoursesÚupdated_countÚcreated_countr   Ú
hostel_feeÚcreated© r7   úL/var/www/apihucms/courses/management/commands/update_business_hostel_fees.pyÚhandle	   sf   *þ 

€$  ü
þ
$zCommand.handleN)Ú__name__Ú
__module__Ú__qualname__Úhelpr9   r7   r7   r7   r8   r      s    r   )	ÚosÚdjango.core.management.baser   Úcourses.modelsr   r   Úcolleges.modelsr   r   r7   r7   r7   r8   Ú<module>   s
    