o
    &^h                     @   s@   d dl mZ d dlmZmZmZ d dlmZ G dd deZdS )    )BaseCommand)CollegeProgramsSectionProgram)Coursec                   @   s   e Zd ZdZdd ZdS )CommandzGUpdate the Programs section for Roorkee College of Agriculture Sciencesc              
   O   s`  zt jjdd}tjj|ddddd\}}|j   g d}tjj	|d	}g }d
}	d
}
|D ]A}|j
}|j}|dsB|drU||d| dd|	d |	d
7 }	q0|ds_|drq||d| dd|
d |
d
7 }
q0d}|D ])}tjj||d |d |d |d d}|d
7 }| jd|j d|  d qv| j| jd|j d| d | jd  | j| jd! | jd" |jj	dd# }|jj	dd# }| jd$|  | jd%|  | jd&|  W d S  t jy   | j| jd' Y d S  ty/ } z| j| jd(t|  W Y d }~d S d }~ww ))Nz'roorkee-college-of-agriculture-sciences)slugzPrograms Offereda*  Comprehensive agricultural sciences and food technology programs designed to address modern agricultural challenges and sustainable development. Our diverse range of undergraduate and postgraduate programs prepare students for careers in agriculture, food technology, nutrition, and related fields.F)titledescriptionhas_doctoral_programs)collegedefaults)zB.Sc. Agriculture Hons.z!M.Sc. Agriculture (with Agronomy)z%M.Sc. Agriculture (with Horticulture)z(M.Sc. Agriculture (with Plant Pathology)zB.Sc. Food TechnologyzB.Sc. Nutrition & Dietetics)	title__in   zB.Sc.zB.z/academics/programs/courses//UG)namelinktypeorderzM.Sc.zM.PGr   r   r   r   r   )programs_sectionr   r   program_typer   zCreated program: z ()zSuccessfully updated z with z
 programs!z3
==================================================zPROGRAMS SUMMARY:z2==================================================)r   zUndergraduate Programs: zPostgraduate Programs: zTotal Programs: z&Agriculture Sciences college not foundzError updating programs: )r   objectsgetr   get_or_createprogramsalldeleter   filterr	   r   
startswithappendr   createstdoutwriter   get_program_type_displaystyleSUCCESScountDoesNotExistERROR	Exceptionstr)selfargsoptionsr   r   createdagriculture_course_titlesagriculture_coursesprograms_dataorder_ugorder_pgcoursecourse_namecourse_slugcreated_countprogram_dataprogramug_programspg_programse r@   M/var/www/apihucms/colleges/management/commands/update_agriculture_programs.pyhandle   s   




"

zCommand.handleN)__name__
__module____qualname__helprB   r@   r@   r@   rA   r      s    r   N)	django.core.management.baser   colleges.modelsr   r   r   courses.modelsr   r   r@   r@   r@   rA   <module>   s    