How to use project_name method in dbt-osmosis

Best Python code snippet using dbt-osmosis_python

admin.py

Source:admin.py Github

copy

Full Screen

1from django.contrib import admin2from .models import *3# Register your models here.4class ProjectIconsAdmin(admin.ModelAdmin):5 list_display = ('id', 'icon', 'site_owner', 'created_at', 'updated_at', 'is_active')6 list_display_links = ('site_owner', )7 search_fields = ('site_owner', )8 list_editable = ('is_active',)9admin.site.register(ProjectIcons, ProjectIconsAdmin)10class BtsProjectAdmin(admin.ModelAdmin):11 list_display = ('id', 'bts_project_name', 'icon', 'created_at', 'updated_at', 'is_active')12 list_display_links = ('bts_project_name', )13 search_fields = ('bts_project_name', )14 list_editable = ('is_active',)15admin.site.register(BtsProject, BtsProjectAdmin)16class BtsSiteAdmin(admin.ModelAdmin):17 list_display = ('id', 'project_name', 'icon', 'site_number', 'BTS_type', 'site_owner', 'geotech_file','geotech_file_comment', 'access_letter', 'access_letter_comment','approved_drawing','final_acceptance_cert', 'final_acceptance_cert_comment',18 'location', 'created_by', 'status', 'turn_around_time','rof_8','rof_8_comment','sign_off','sign_off_comment','rfi','rfi_comment','integration_parameter','integration_parameter_comment','ip_plan','ip_plan_comment')19 list_display_links = ('project_name', )20 search_fields = ('project_name', )21admin.site.register(BtsSite, BtsSiteAdmin)22class IRROF7FreeAdmin(admin.ModelAdmin):23 list_display = ('id', 'project_name', 'tower_complete','tower_complete_comment', 'free_issue_material','free_issue_material_comment', 'link_material','link_material_comment', 'posted_by', 'is_approved')24 list_display_links = ('project_name', )25 search_fields = ('project_name', )26admin.site.register(IRROF7Free, IRROF7FreeAdmin)27class BtsBudgetAdmin(admin.ModelAdmin):28 list_display = ('id', 'project_name', 'beneficiary_name','description', 'date','phoneNumber','quantity', 'rate','unit','amount','is_approved','created_at', 'updated_at', 'is_active')29 list_display_links = ('project_name', )30 search_fields = ('project_name', )31 list_editable = ('is_active',)32admin.site.register(BtsBudget, BtsBudgetAdmin)33class AccessApprovalCivilAdmin(admin.ModelAdmin):34 list_display = ('id', 'project_name', 'access_approval', 'access_approval_comment',35 'created_at', 'updated_at', 'is_active')36 list_display_links = ('project_name', )37 search_fields = ('project_name', )38 list_editable = ('is_active',)39admin.site.register(AccessApprovalCivil, AccessApprovalCivilAdmin)40class AccessApprovalInstallationAdmin(admin.ModelAdmin):41 list_display = ('id', 'project_name', 'access_approval', 'access_approval_comment',42 'created_at', 'updated_at', 'is_active')43 list_display_links = ('project_name', )44 search_fields = ('project_name', )45 list_editable = ('is_active',)46admin.site.register(AccessApprovalInstallation, AccessApprovalInstallationAdmin)47class ProjectCostingAdmin(admin.ModelAdmin):48 list_display = ('id', 'project_name', 'project_costing_file', 'material_cost',49 'labour_cost', 'total_projected_cost', 'is_approved',50 'created_at', 'updated_at', 'is_active')51 list_display_links = ('project_name', )52 search_fields = ('project_name', )53 list_editable = ('is_active', 'is_approved')54admin.site.register(ProjectCosting, ProjectCostingAdmin)55class ProjectPurchaseOrdersAdmin(admin.ModelAdmin):56 list_display = ('id', 'project_name', 'po_file', 'material_cost',57 'labour_cost', 'total_cost_of_po', 'is_approved',58 'created_at', 'updated_at', 'is_active')59 list_display_links = ('project_name', )60 search_fields = ('project_name', )61 list_editable = ('is_active', 'is_approved')62admin.site.register(ProjectPurchaseOrders, ProjectPurchaseOrdersAdmin)63class CommercialTeamAdmin(admin.ModelAdmin):64 list_display = ('id', 'project_name', 'approved_quote_file', 'approved_quote_amount', 'po_data','drawings_revised_approved','tower_type_allocated',65 'material_collection_from_steel_supplier','PO_steel_fabrication','customer_issued_quotation','project_costing_data','initial_invoice', 'initial_invoice_comment', 'posted_by', 'is_approved', 'created_at', 'updated_at', 'is_active')66 list_display_links = ('project_name', )67 list_filter = ('project_name',)68 search_fields = ('project_name', )69 list_editable = ('is_active', 'is_approved')70admin.site.register(CommercialTeam, CommercialTeamAdmin)71class ProcurementTeamAdmin(admin.ModelAdmin):72 list_display = ('id', 'project_name', 'po_steel', 'po_electrical_materials', 'po_subcontractors', 'po_subcontractors_amount', 'posted_by', 'is_approved', 'created_at', 'updated_at', 'is_active')73 list_display_links = ('project_name', )74 list_filter = ('project_name',)75 search_fields = ('project_name', )76 list_editable = ('is_active', 'is_approved')77admin.site.register(ProcurementTeam, ProcurementTeamAdmin)78class HealthDocumentsCivilTeamAdmin(admin.ModelAdmin):79 list_display = ('id', 'project_name', 'job_hazard_form', 'job_hazard_form_comment', 'incident_notification_form', 'incident_notification_form_comment', 'toolbox_meeting_form',80 'toolbox_meeting_form_comment', 'communication_plan_form', 'communication_plan_form_comment', 'health_documents_comment','access_approval', 'safety_picture','posted_by', 'is_approved', 'created_at', 'updated_at', 'is_active')81 list_display_links = ('project_name', )82 list_filter = ('project_name',)83 search_fields = ('project_name', )84 list_editable = ('is_active', 'is_approved')85admin.site.register(HealthDocumentsCivilTeam, HealthDocumentsCivilTeamAdmin)86#87# ####################################### KPI ###############################################################################################################################88#89# class KpiAdmin(admin.ModelAdmin):90# list_display = ('id', 'kpi', 'posted_by', 'is_approved', 'created_at', 'updated_at', 'is_active')91# list_display_links = ('kpi', )92# search_fields = ('kpi', )93# list_editable = ('is_active', 'is_approved')94#95#96# admin.site.register(Kpi, KpiAdmin)97#98# ######################################## END #######################################################################################################################################99#100# ####################################### TASKS #################################################################################################,'track_docs'##############################101#102#103# class TaskAdmin(admin.ModelAdmin):104# list_display = ('id', 'category_name','task_name', 'kpi', 'posted_by', 'is_approved', 'created_at', 'updated_at', 'is_active')105# list_display_links = ('task_name', )106# list_filter = ('category_name',)107# search_fields = ('task_name', )108# list_editable = ('is_active', 'is_approved')109#110#111# admin.site.register(Task, TaskAdmin)112# ######################################## END #######################################################################################################################################113#114# ####################################### SUBTASKS ###############################################################################################################################115#116# class SubTaskAdmin(admin.ModelAdmin):117# list_display = ('id', 'task_name', 'subtask_name', 'kpi','posted_by', 'is_approved', 'created_at', 'updated_at', 'is_active')118# list_display_links = ('subtask_name', )119# list_filter = ('task_name',)120# search_fields = ('subtask_name', )121# list_editable = ('is_active', 'is_approved')122#123#124# admin.site.register(SubTask, SubTaskAdmin)125#126# ######################################## END #######################################################################################################################################127#######################################START FOUNDATION IMAGES########################################################################################################################################128class FoundationImageAdmin(admin.ModelAdmin):129 list_display = ('id', 'project_name', 'team_task_id', 'setting_site_clearing', 'excavation_tower_base', 'binding', 'steel_fix_formwork','concrete_pour_curing_period', 'concrete_curing_period','dom_equipment','foundation_and_curing_comment','engineers', 'names_of_engineers','start_date','end_date', 'raise_flag','created_at', 'updated_at', 'is_active')130 list_display_links = ('project_name', )131 list_filter = ('project_name',)132 search_fields = ('project_name', )133 list_editable = ('is_active',)134admin.site.register(FoundationImage, FoundationImageAdmin)135class SetSiteClearingImageAdmin(admin.ModelAdmin):136 list_display = ('id', 'project_name','task_id', 'setting_site_clearing_image_1', 'setting_site_clearing_image_2', 'setting_site_clearing_image_3', 'setting_site_clearing_comment', 'no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'labour_cost', 'date_casual_cost', 'check_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')137 list_display_links = ('project_name', )138 list_filter = ('project_name',)139 search_fields = ('project_name', )140 list_editable = ('is_active',)141admin.site.register(SetSiteClearingImage, SetSiteClearingImageAdmin)142class TowerBaseImageAdmin(admin.ModelAdmin):143 list_display = ('id', 'project_name','task_id', 'towerbase_image_1', 'towerbase_image_2', 'towerbase_image_3', 'tower_base_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')144 list_display_links = ('project_name', )145 list_filter = ('project_name',)146 search_fields = ('project_name', )147 list_editable = ('is_active',)148admin.site.register(TowerBaseImage, TowerBaseImageAdmin)149class BindingImageAdmin(admin.ModelAdmin):150 list_display = ('id', 'project_name', 'task_id', 'binding_image_1', 'binding_image_2', 'binding_image_3', 'binding_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')151 list_display_links = ('project_name', )152 list_filter = ('project_name',)153 search_fields = ('project_name', )154 list_editable = ('is_active',)155admin.site.register(BindingImage, BindingImageAdmin)156class SteelFixFormworkImageAdmin(admin.ModelAdmin):157 list_display = ('id', 'project_name', 'task_id', 'steel_fix_formwork_image_1', 'steel_fix_formwork_image_2', 'steel_fix_formwork_image_3', 'steel_fix_formwork_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')158 list_display_links = ('project_name', )159 list_filter = ('project_name',)160 search_fields = ('project_name', )161 list_editable = ('is_active',)162admin.site.register(SteelFixFormworkImage, SteelFixFormworkImageAdmin)163class ConcretePourImageAdmin(admin.ModelAdmin):164 list_display = ('id', 'project_name', 'task_id', 'concrete_pour_curing_image_1', 'concrete_pour_curing_image_2', 'concrete_pour_curing_image_3', 'concrete_pour_curing_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')165 list_display_links = ('project_name', )166 list_filter = ('project_name',)167 search_fields = ('project_name', )168 list_editable = ('is_active',)169admin.site.register(ConcretePourImage, ConcretePourImageAdmin)170class ConcreteCuringPeriodDocsAdmin(admin.ModelAdmin):171 list_display = ('id', 'project_name', 'Rebar_Concrete_Inspection', 'Concrete_Inspection_Report', 'Concrete_Cube_Test','created_at', 'updated_at', 'is_active')172 list_display_links = ('project_name', )173 list_filter = ('project_name',)174 search_fields = ('project_name', )175 list_editable = ('is_active',)176admin.site.register(ConcreteCuringPeriodDocs, ConcreteCuringPeriodDocsAdmin)177class ConcreteCuringPeriodImageAdmin(admin.ModelAdmin):178 list_display = ('id', 'project_name', 'task_id', 'concrete_pour_curing_period_image_1', 'concrete_pour_curing_period_image_2', 'concrete_pour_curing_period_image_3', 'concrete_pour_curing_period_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')179 list_display_links = ('project_name', )180 list_filter = ('project_name',)181 search_fields = ('project_name', )182 list_editable = ('is_active',)183admin.site.register(ConcreteCuringPeriodImage, ConcreteCuringPeriodImageAdmin)184class DeliveryOfMaterialandEquipementAdmin(admin.ModelAdmin):185 list_display = ('id', 'project_name', 'task_id', 'dom_equipment_image_1', 'dom_equipment_image_2', 'dom_equipment_image_3', 'dom_equipment_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')186 list_display_links = ('project_name', )187 list_filter = ('project_name',)188 search_fields = ('project_name', )189 list_editable = ('is_active',)190admin.site.register(DeliveryOfMaterialandEquipement, DeliveryOfMaterialandEquipementAdmin)191######################################## END #######################################################################################################################################192#######################################BS241 & GENERATOR FOUNDATION ###########################################################################################################################193class ExcavationImageAdmin(admin.ModelAdmin):194 list_display = ('id', 'project_name', 'task_id', 'excavation_image_1', 'excavation_image_2', 'excavation_image_3', 'excavation_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'raise_flag','start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')195 list_display_links = ('project_name', )196 list_filter = ('project_name',)197 search_fields = ('project_name', )198 list_editable = ('is_active',)199admin.site.register(ExcavationImage, ExcavationImageAdmin)200class BS241ConcretePourCuringPeriodImageAdmin(admin.ModelAdmin):201 list_display = ('id', 'project_name', 'task_id', 'bs241_concrete_pour_curing_period_image_1', 'bs241_concrete_pour_curing_period_image_2','bs241_concrete_pour_curing_period_image_3', 'bs241_concrete_pour_curing_period_comment', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')202 list_display_links = ('project_name', )203 list_filter = ('project_name',)204 search_fields = ('project_name', )205 list_editable = ('is_active',)206admin.site.register(BS241ConcretePourCuringPeriodImage, BS241ConcretePourCuringPeriodImageAdmin)207class BS241ImageAdmin(admin.ModelAdmin):208 list_display = ('id', 'project_name', 'task_id', 'bs241_image_1', 'bs241_image_2','bs241_image_3', 'bs241_comment', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')209 list_display_links = ('project_name', )210 list_filter = ('project_name',)211 search_fields = ('project_name', )212 list_editable = ('is_active',)213admin.site.register(BS241Image, BS241ImageAdmin)214class BS241AndGeneatorSlabsImageAdmin(admin.ModelAdmin):215 list_display = ('id', 'project_name', 'team_task_id', 'foundation_foot_pouring', 'bs241_concrete_pour_pouring_period','bs241_and_generator_slabs_comment','engineers', 'names_of_engineers', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')216 list_display_links = ('project_name', )217 list_filter = ('project_name',)218 search_fields = ('project_name', )219 list_editable = ('is_active',)220admin.site.register(BS241AndGeneatorSlabsImage, BS241AndGeneatorSlabsImageAdmin)221######################################## END #######################################################################################################################################222#######################################GENERATOR SLABS FOUNDATION ###########################################################################################################################223class GenExcavationImageAdmin(admin.ModelAdmin):224 list_display = ('id', 'project_name', 'task_id', 'gen_excavation_image_1', 'gen_excavation_image_2', 'gen_excavation_image_3', 'gen_excavation_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'raise_flag','start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')225 list_display_links = ('project_name', )226 list_filter = ('project_name',)227 search_fields = ('project_name', )228 list_editable = ('is_active',)229admin.site.register(GenExcavationImage, GenExcavationImageAdmin)230class GenConcretePourCuringPeriodImageAdmin(admin.ModelAdmin):231 list_display = ('id', 'project_name', 'task_id', 'gen_concrete_pour_period_image_1', 'gen_concrete_pour_period_image_2','gen_concrete_pour_period_image_3', 'gen_concrete_pour_period_comment', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')232 list_display_links = ('project_name', )233 list_filter = ('project_name',)234 search_fields = ('project_name', )235 list_editable = ('is_active',)236admin.site.register(GenConcretePourCuringPeriodImage, GenConcretePourCuringPeriodImageAdmin)237class GenCableConduitsSettingImageAdmin(admin.ModelAdmin):238 list_display = ('id', 'project_name', 'task_id', 'gen_cable_conduits_image_1', 'gen_cable_conduits_image_2','gen_cable_conduits_image_3', 'gen_cable_conduits_comment', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')239 list_display_links = ('project_name', )240 list_filter = ('project_name',)241 search_fields = ('project_name', )242 list_editable = ('is_active',)243admin.site.register(GenCableConduitsSettingImage, GenCableConduitsSettingImageAdmin)244class GeneatorSlabsImageAdmin(admin.ModelAdmin):245 list_display = ('id', 'project_name', 'team_task_id', 'gen_excavation', 'gen_concrete_pour_period','gen_cable_conduits','generator_slabs_comment','engineers', 'names_of_engineers', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')246 list_display_links = ('project_name', )247 list_filter = ('project_name',)248 search_fields = ('project_name', )249 list_editable = ('is_active',)250admin.site.register(GeneatorSlabsImage, GeneatorSlabsImageAdmin)251######################################## END #######################################################################################################################################252####################################### FABRICATION ###########################################################################################################################253class FabricationQualityInspectionImageAdmin(admin.ModelAdmin):254 list_display = ('id', 'project_name','task_id','start_date','end_date', 'fabrication_quality_inspection_image_1','fabrication_quality_inspection_image_2','fabrication_quality_inspection_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','fabrication_quality_inspection_image_comment')255 list_display_links = ('project_name', )256 search_fields = ('project_name', )257admin.site.register(FabricationQualityInspectionImage, FabricationQualityInspectionImageAdmin)258class FabricationSteelDeckImageAdmin(admin.ModelAdmin):259 list_display = ('id', 'project_name','task_id','start_date','end_date', 'fabrication_steel_deck_image_1','fabrication_steel_deck_image_2','fabrication_steel_deck_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','fabrication_steel_deck_image_comment')260 list_display_links = ('project_name', )261 search_fields = ('project_name', )262admin.site.register(FabricationSteelDeckImage, FabricationSteelDeckImageAdmin)263class GalvanisationImageAdmin(admin.ModelAdmin):264 list_display = ('id', 'project_name','start_date','end_date', 'galvanisation_image_1','galvanisation_image_2','galvanisation_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','galvanisation_image_comment')265 list_display_links = ('project_name', )266 search_fields = ('project_name', )267admin.site.register(GalvanisationImage, GalvanisationImageAdmin)268class FabricationRooftopImageAdmin(admin.ModelAdmin):269 list_display = ('id', 'project_name','team_task_id','start_date','end_date','engineers', 'names_of_engineers','raise_flag','fabrication_quality_inspection_image','fabrication_steel_deck_image','galvanization_image','fabrication_rooftop_image_comment')270 list_display_links = ('project_name', )271 search_fields = ('project_name', )272admin.site.register(FabricationRooftopImage, FabricationRooftopImageAdmin)273######################################## END #######################################################################################################################################274####################################### BOUNDARY WALL ###########################################################################################################################275class FoundFootPourImageAdmin(admin.ModelAdmin):276 list_display = ('id', 'project_name', 'task_id', 'foundfootpour_image_1', 'foundfootpour_image_2', 'foundfootpour_image_3', 'foundfootpour_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')277 list_display_links = ('project_name', )278 list_filter = ('project_name',)279 search_fields = ('project_name', )280 list_editable = ('is_active',)281admin.site.register(FoundFootPourImage, FoundFootPourImageAdmin)282class BlockworkPanelConstImageAdmin(admin.ModelAdmin):283 list_display = ('id', 'project_name', 'task_id', 'blockwallpanelconst_image_1', 'blockwallpanelconst_image_2', 'blockwallpanelconst_image_3', 'blockwallpanelconst_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')284 list_display_links = ('project_name', )285 list_filter = ('project_name',)286 search_fields = ('project_name', )287 list_editable = ('is_active',)288admin.site.register(BlockworkPanelConstImage, BlockworkPanelConstImageAdmin)289class GateInstallationImageAdmin(admin.ModelAdmin):290 list_display = ('id', 'project_name', 'task_id', 'gateinstallation_image_1', 'gateinstallation_image_2', 'gateinstallation_image_3','gateinstallation_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')291 list_display_links = ('project_name', )292 list_filter = ('project_name',)293 search_fields = ('project_name', )294 list_editable = ('is_active',)295admin.site.register(GateInstallationImage, GateInstallationImageAdmin)296class RazorElectricFenceImageAdmin(admin.ModelAdmin):297 list_display = ('id', 'project_name', 'task_id', 'razorelectricfance_image_1', 'razorelectricfance_image_2', 'razorelectricfance_image_3', 'razorelectricfance_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')298 list_display_links = ('project_name', )299 list_filter = ('project_name',)300 search_fields = ('project_name', )301 list_editable = ('is_active',)302admin.site.register(RazorElectricFenceImage, RazorElectricFenceImageAdmin)303class BWConcretePourCuringPeriodImageAdmin(admin.ModelAdmin):304 list_display = ('id', 'project_name', 'task_id', 'bw_concrete_pour_curing_period_image_1', 'bw_concrete_pour_curing_period_image_2', 'bw_concrete_pour_curing_period_image_3', 'bw_concrete_pour_curing_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')305 list_display_links = ('project_name', )306 list_filter = ('project_name',)307 search_fields = ('project_name', )308 list_editable = ('is_active',)309admin.site.register(BWConcretePourCuringPeriodImage, BWConcretePourCuringPeriodImageAdmin)310class ExcavationstripFoundationsImageAdmin(admin.ModelAdmin):311 list_display = ('id', 'project_name', 'task_id', 'excavationstrip_foundations_image_1', 'excavationstrip_foundations_image_2', 'excavationstrip_foundations_image_3', 'excavationstrip_foundations_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')312 list_display_links = ('project_name', )313 list_filter = ('project_name',)314 search_fields = ('project_name', )315 list_editable = ('is_active',)316admin.site.register(ExcavationstripFoundationsImage, ExcavationstripFoundationsImageAdmin)317class BWBlindingImageAdmin(admin.ModelAdmin):318 list_display = ('id', 'project_name', 'task_id', 'bw_blinding_image_1', 'bw_blinding_image_2', 'bw_blinding_image_3', 'bw_blinding_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')319 list_display_links = ('project_name', )320 list_filter = ('project_name',)321 search_fields = ('project_name', )322 list_editable = ('is_active',)323admin.site.register(BWBlindingImage, BWBlindingImageAdmin)324class BWCableConduitsImageAdmin(admin.ModelAdmin):325 list_display = ('id', 'project_name', 'task_id', 'bw_cable_conduits_image_1', 'bw_cable_conduits_image_2', 'bw_cable_conduits_image_3', 'bw_cable_conduits_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')326 list_display_links = ('project_name', )327 list_filter = ('project_name',)328 search_fields = ('project_name', )329 list_editable = ('is_active',)330admin.site.register(BWCableConduitsImage, BWCableConduitsImageAdmin)331class BoundaryWallImageAdmin(admin.ModelAdmin):332 list_display = ('id', 'project_name', 'team_task_id', 'foundation_foot_pouring', 'block_construction', 'gate_installation', 'razor_electric_fence','boundary_wall_comment','engineers', 'names_of_engineers', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')333 list_display_links = ('project_name', )334 list_filter = ('project_name',)335 search_fields = ('project_name', )336 list_editable = ('is_active',)337admin.site.register(BoundaryWallImage, BoundaryWallImageAdmin)338####################################### END###########################################################################################################################339####################################### MANHOLE SETTING OUT CONSTRUCTION ###########################################################################################################################340class ManholeSettingExcavationImageAdmin(admin.ModelAdmin):341 list_display = ('id', 'project_name','start_date','end_date', 'manhole_setting_excavation_image_1','manhole_setting_excavation_image_2','manhole_setting_excavation_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','manhole_setting_excavation_image_comment')342 list_display_links = ('project_name', )343 search_fields = ('project_name', )344admin.site.register( ManholeSettingExcavationImage, ManholeSettingExcavationImageAdmin)345class ManholeBlindingAdmin(admin.ModelAdmin):346 list_display = ('id', 'project_name','start_date','end_date', 'manhole_blinding_image_1','manhole_blinding_image_2','manhole_blinding_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','manhole_blinding_image_comment')347 list_display_links = ('project_name', )348 search_fields = ('project_name', )349admin.site.register( ManholeBlinding, ManholeBlindingAdmin)350class ManholeBlockworkAdmin(admin.ModelAdmin):351 list_display = ('id', 'project_name','start_date','end_date', 'manhole_blindingwork_image_1','manhole_blindingwork_image_2','manhole_blindingwork_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','manhole_blindingwork_image_comment')352 list_display_links = ('project_name', )353 search_fields = ('project_name', )354admin.site.register( ManholeBlockwork, ManholeBlockworkAdmin)355class ManholeSettingOutConstructionImageAdmin(admin.ModelAdmin):356 list_display = ('id', 'project_name','team_task_id','start_date','end_date','engineers', 'names_of_engineers','raise_flag','manhole_setting_excavation_image','manhole_blinding_image','manhole_blockwork_image','manhole_setting_out_construction_image_comment')357 list_display_links = ('project_name', )358 search_fields = ('project_name', )359admin.site.register( ManholeSettingOutConstructionImage, ManholeSettingOutConstructionImageAdmin)360####################################### END ###########################################################################################################################361####################################### TOWER & ANTENNA_COAX ###########################################################################################################################362class TowerErectionImageAdmin(admin.ModelAdmin):363 list_display = ('id', 'project_name', 'task_id', 'tower_erection_image_1', 'tower_erection_image_2', 'tower_erection_image_3', 'tower_erection_comment', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')364 list_display_links = ('project_name', )365 list_filter = ('project_name',)366 search_fields = ('project_name', )367 list_editable = ('is_active',)368admin.site.register(TowerErectionImage, TowerErectionImageAdmin)369class TowerPaintImageAdmin(admin.ModelAdmin):370 list_display = ('id', 'project_name', 'task_id', 'tower_painting_image_1', 'tower_painting_image_2', 'tower_painting_image_3', 'tower_painting_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost','engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')371 list_display_links = ('project_name', )372 list_filter = ('project_name',)373 search_fields = ('project_name', )374 list_editable = ('is_active',)375admin.site.register(TowerPaintImage, TowerPaintImageAdmin)376class CableWaysImageAdmin(admin.ModelAdmin):377 list_display = ('id', 'project_name', 'task_id', 'cable_ways_image_1', 'cable_ways_image_2', 'cable_ways_image_3','cable_ways_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost','engineers_cost', 'start_date','end_date','created_at', 'updated_at', 'is_active')378 list_display_links = ('project_name', )379 list_filter = ('project_name',)380 search_fields = ('project_name', )381 list_editable = ('is_active',)382admin.site.register(CableWaysImage, CableWaysImageAdmin)383class AntennaCoaxInstallImageAdmin(admin.ModelAdmin):384 list_display = ('id', 'project_name', 'task_id', 'antenna_coax_installation_image_1', 'antenna_coax_installation_image_2', 'antenna_coax_installation_image_3', 'antenna_coax_installation_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost','engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')385 list_display_links = ('project_name', )386 list_filter = ('project_name',)387 search_fields = ('project_name', )388 list_editable = ('is_active',)389admin.site.register(AntennaCoaxInstallImage, AntennaCoaxInstallImageAdmin)390class EarthInstallationImageAdmin(admin.ModelAdmin):391 list_display = ('id', 'project_name', 'task_id', 'earth_Installation_image_1', 'earth_Installation_image_2', 'earth_Installation_image_3', 'earth_Installation_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')392 list_display_links = ('project_name', )393 list_filter = ('project_name',)394 search_fields = ('project_name', )395 list_editable = ('is_active',)396admin.site.register(EarthInstallationImage, EarthInstallationImageAdmin)397class CableInstallationImageAdmin(admin.ModelAdmin):398 list_display = ('id', 'project_name', 'task_id', 'cable_installation_image_1', 'cable_installation_image_2', 'cable_installation_image_3', 'cable_installation_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')399 list_display_links = ('project_name', )400 list_filter = ('project_name',)401 search_fields = ('project_name', )402 list_editable = ('is_active',)403admin.site.register(CableInstallationImage, CableInstallationImageAdmin)404class AviationLightsInstallationImageAdmin(admin.ModelAdmin):405 list_display = ('id', 'project_name', 'task_id', 'aviation_lights_installation_image_1', 'aviation_lights_installation_image_2', 'aviation_lights_installation_image_3', 'aviation_lights_installation_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')406 list_display_links = ('project_name', )407 list_filter = ('project_name',)408 search_fields = ('project_name', )409 list_editable = ('is_active',)410admin.site.register(AviationLightsInstallationImage, AviationLightsInstallationImageAdmin)411class TowerDeliveryImageAdmin(admin.ModelAdmin):412 list_display = ('id', 'project_name', 'task_id', 'tower_delivery_image_1', 'tower_delivery_image_2', 'tower_delivery_image_3', 'tower_delivery_comment','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')413 list_display_links = ('project_name', )414 list_filter = ('project_name',)415 search_fields = ('project_name', )416 list_editable = ('is_active',)417admin.site.register(TowerDeliveryImage, TowerDeliveryImageAdmin)418class TowerAntennaCoaxImageAdmin(admin.ModelAdmin):419 list_display = ('id', 'project_name', 'team_task_id', 'tower_erection', 'tower_painting', 'cable_ways', 'antenna_coax_installation','tower_delivery','aviation_lights_installation_image',420 'earth_installation','cable_installation','tower_antenna_coax_comment','engineers', 'names_of_engineers', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')421 list_display_links = ('project_name', )422 list_filter = ('project_name',)423 search_fields = ('project_name', )424 list_editable = ('is_active',)425admin.site.register(TowerAntennaCoaxImage, TowerAntennaCoaxImageAdmin)426####################################### END###########################################################################################################################427class BTSinstallationTaskAdmin(admin.ModelAdmin):428 list_display = ('id', 'project_name', 'task_id', 'no_of_casuals', 'names_of_casuals', 'casuals_cost','engineers_cost', 'start_date', 'BTSinstallation_image_1', 'BTSinstallation_image_2', 'BTSinstallation_image_3', 'BTSinstallation_comment',429 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')430 list_display_links = ('project_name', )431 list_filter = ('project_name',)432 search_fields = ('project_name', )433 list_editable = ('is_active',)434admin.site.register(BTSinstallationTask, BTSinstallationTaskAdmin)435class MWInstallationTaskAdmin(admin.ModelAdmin):436 list_display = ('id', 'project_name', 'task_id', 'no_of_casuals', 'names_of_casuals', 'casuals_cost','engineers_cost', 'start_date','MWinstallation_image_1', 'MWinstallation_image_2', 'MWinstallation_image_3', 'MWinstallation_comment',437 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')438 list_display_links = ('project_name', )439 list_filter = ('project_name',)440 search_fields = ('project_name', )441 list_editable = ('is_active',)442admin.site.register(MWInstallationTask, MWInstallationTaskAdmin)443class TelecomTasksAdmin(admin.ModelAdmin):444 list_display = ('id', 'project_name', 'team_task_id', 'engineers', 'names_of_engineers', 'Installation_of_BTS', 'Installation_of_MW_links', 'link_commissioning', 'is_approved',445 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')446 list_display_links = ('project_name', )447 list_filter = ('project_name',)448 search_fields = ('project_name', )449 list_editable = ('is_active', 'is_approved')450admin.site.register(TelecomTasks, TelecomTasksAdmin)451class UndergroundTasksAdmin(admin.ModelAdmin):452 list_display = ('id', 'project_name', 'task_id', 'no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date', 'Underground_ducting_and_manholes_image_1', 'Underground_ducting_and_manholes_image_2', 'Underground_ducting_and_manholes_image_3', 'Underground_ducting_and_manholes_images_comment',453 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')454 list_display_links = ('project_name', )455 list_filter = ('project_name',)456 search_fields = ('project_name', )457 list_editable = ('is_active',)458admin.site.register(UndergroundTasks, UndergroundTasksAdmin)459class ReticulationAPSinstallationAdmin(admin.ModelAdmin):460 list_display = ('id', 'project_name', 'task_id', 'no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date', 'Electricalreticulation_APSInstallation_image_1', 'Electricalreticulation_APSInstallation_image_2', 'Electricalreticulation_APSInstallation_image_3', 'Electricalreticulation_APSInstallation_images_comment',461 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')462 list_display_links = ('project_name', )463 list_filter = ('project_name',)464 search_fields = ('project_name', )465 list_editable = ('is_active',)466admin.site.register(ReticulationAPSinstallation, ReticulationAPSinstallationAdmin)467class ElectricalEarthingAdmin(admin.ModelAdmin):468 list_display = ('id', 'project_name', 'task_id', 'no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date', 'Earthing_connections_and_testing_image_1', 'Earthing_connections_and_testing_image_2', 'Earthing_connections_and_testing_image_3', 'Earthing_connections_and_testing_images_comment',469 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')470 list_display_links = ('project_name', )471 list_filter = ('project_name',)472 search_fields = ('project_name', )473 list_editable = ('is_active',)474admin.site.register(ElectricalEarthing, ElectricalEarthingAdmin)475class GeneratorInstallationAdmin(admin.ModelAdmin):476 list_display = ('id', 'project_name', 'task_id', 'no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date', 'Generator_and_Fuel_Tank_Installation_image_1', 'Generator_and_Fuel_Tank_Installation_image_2', 'Generator_and_Fuel_Tank_Installation_image_3', 'before_fuel_image_1',477 'before_fuel_image_2', 'after_fuel_image_1', 'after_fuel_image_2', 'Generator_and_Fuel_Tank_Installation_comment', 'start_date','end_date','raise_flag', 'created_at', 'updated_at', 'is_active')478 list_display_links = ('project_name', )479 list_filter = ('project_name',)480 search_fields = ('project_name', )481 list_editable = ('is_active',)482admin.site.register(GeneratorInstallation, GeneratorInstallationAdmin)483class KPLCSolarImageAdmin(admin.ModelAdmin):484 list_display = ('id', 'project_name', 'task_id', 'no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost', 'start_date', 'kplc_solar_installation_image_1', 'kplc_solar_installation_image_2', 'kplc_solar_installation_image_3', 'kplc_solar_installation_comment',485 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')486 list_display_links = ('project_name', )487 list_filter = ('project_name',)488 search_fields = ('project_name', )489 list_editable = ('is_active',)490admin.site.register(KPLCSolarImage, KPLCSolarImageAdmin)491class ElectricalTasksAdmin(admin.ModelAdmin):492 list_display = ('id', 'project_name', 'team_task_id', 'engineers', 'names_of_engineers', 'Underground_ducting_and_manholes', 'Electricalreticulation_APSInstallation', 'Earthing_connections_and_testing', 'Generator_and_Fuel_Tank_Installation', 'KPLC_solar_installation',493 'is_approved', 'start_date','end_date','raise_flag','created_at', 'updated_at', 'is_active')494 list_display_links = ('project_name', )495 list_filter = ('project_name',)496 search_fields = ('project_name', )497 list_editable = ('is_active', 'is_approved')498admin.site.register(ElectricalTasks, ElectricalTasksAdmin)499class CivilWorksTeamAdmin(admin.ModelAdmin):500 list_display = ('id', 'project_name', 'health_documents_civil', 'foundation_and_curing_images',501 'bs241_and_generator_slabs_images', 'site_walling_images_field', 'posted_by', 'is_approved', 'created_at', 'updated_at', 'is_active')502 list_display_links = ('project_name', )503 list_filter = ('project_name',)504 search_fields = ('project_name', )505 list_editable = ('is_active',)506admin.site.register(CivilWorksTeam, CivilWorksTeamAdmin)507class HealthDocumentsInstallationTeamAdmin(admin.ModelAdmin):508 list_display = ('id', 'project_name', 'job_hazard_form', 'job_hazard_form_comment', 'incident_notification_form', 'incident_notification_form_comment', 'toolbox_meeting_form',509 'toolbox_meeting_form_comment', 'communication_plan_form', 'communication_plan_form_comment', 'health_documents_comment', 'access_approval', 'safety_picture', 'posted_by', 'is_approved', 'created_at', 'updated_at', 'is_active')510 list_display_links = ('project_name', )511 list_filter = ('project_name',)512 search_fields = ('project_name', )513 list_editable = ('is_active',)514admin.site.register(HealthDocumentsInstallationTeam, HealthDocumentsInstallationTeamAdmin)515class IssuesAdmin(admin.ModelAdmin):516 list_display = ('id', 'project_name', 'issue', 'issue_image', 'issue_sorted_image', 'closed', 'posted_by', 'created_at', 'updated_at', 'is_active')517 list_display_links = ('issue', )518 list_filter = ('project_name',)519 search_fields = ('issue', )520 list_editable = ('is_active',)521admin.site.register(Issues, IssuesAdmin)522class InstallationTeamAdmin(admin.ModelAdmin):523 list_display = ('id', 'project_name', 'health_documents_installation', 'electrical_tasks_data',524 'telecom_tasks_data', 'as_built', 'snag_document', 'snag_document_comment',525 'project_issues', 'conditional_acceptance_cert', 'conditional_acceptance_cert_comment', 'posted_by', 'is_approved', 'created_at', 'updated_at', 'is_active')526 list_display_links = ('project_name', )527 list_filter = ('project_name',)528 search_fields = ('project_name', )529 list_editable = ('is_active',)530admin.site.register(InstallationTeam, InstallationTeamAdmin)531class WarrantyCertificateAdmin(admin.ModelAdmin):532 list_display = ('id', 'project_name', 'civilworks_installation_certificate', 'connectors_torque_certificate', 'safe_to_climb_certificate', 'posted_by', 'is_approved', 'created_at', 'updated_at', 'is_active')533 list_display_links = ('project_name', )534 search_fields = ('project_name', )535 list_editable = ('is_active', 'is_approved')536admin.site.register(WarrantyCertificate, WarrantyCertificateAdmin)537class TestCetificateAdmin(admin.ModelAdmin):538 list_display = ('id', 'project_name', 'cube_test_7days', 'cube_test_28days', 'earth_test', 'posted_by', 'is_approved', 'created_at', 'updated_at', 'is_active')539 list_display_links = ('project_name', )540 search_fields = ('project_name', )541 list_editable = ('is_active', 'is_approved')542admin.site.register(TestCetificate, TestCetificateAdmin)543class HackingExistingColumnsImageAdmin(admin.ModelAdmin):544 list_display = ('id', 'project_name','start_date','end_date', 'hacking_existing_columns_image_1','hacking_existing_columns_image_2','hacking_existing_columns_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','hacking_existing_columns_image_comment')545 list_display_links = ('project_name', )546 search_fields = ('project_name', )547admin.site.register(HackingExistingColumnsImage, HackingExistingColumnsImageAdmin)548class FormworkColumnsConcretePourCuringImageAdmin(admin.ModelAdmin):549 list_display = ('id', 'project_name','start_date','end_date', 'formwork_columns_concrete_pour_curing_image_1','formwork_columns_concrete_pour_curing_image_2','formwork_columns_concrete_pour_curing_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','formwork_columns_concrete_pour_curing_image_comment')550 list_display_links = ('project_name', )551 search_fields = ('project_name', )552admin.site.register(FormworkColumnsConcretePourCuringImage, FormworkColumnsConcretePourCuringImageAdmin)553class DeliveryToSiteImageAdmin(admin.ModelAdmin):554 list_display = ('id', 'project_name','start_date','end_date', 'delivery_to_site_image_1','delivery_to_site_image_2','delivery_to_site_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','delivery_to_site_image_comment')555 list_display_links = ('project_name', )556 search_fields = ('project_name', )557admin.site.register(DeliveryToSiteImage, DeliveryToSiteImageAdmin)558class LiftingHoistingFreeIssueImageAdmin(admin.ModelAdmin):559 list_display = ('id', 'project_name','start_date','end_date', 'lifting_hoisting_free_issue_image_1','lifting_hoisting_free_issue_image_2','lifting_hoisting_free_issue_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','lifting_hoisting_free_issue_image_comment')560 list_display_links = ('project_name', )561 search_fields = ('project_name', )562admin.site.register(LiftingHoistingFreeIssueImage, LiftingHoistingFreeIssueImageAdmin)563class FenceInstallationImageAdmin(admin.ModelAdmin):564 list_display = ('id', 'project_name','start_date','end_date', 'fence_installation_image_1','fence_installation_image_2','fence_installation_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','fence_installation_image_comment')565 list_display_links = ('project_name', )566 search_fields = ('project_name', )567admin.site.register(FenceInstallationImage, FenceInstallationImageAdmin)568class SiteRestorationImageAdmin(admin.ModelAdmin):569 list_display = ('id', 'project_name','start_date','end_date', 'site_restoration_image_1','site_restoration_image_2','site_restoration_image_3','no_of_casuals', 'names_of_casuals', 'casuals_cost', 'engineers_cost','raise_flag','site_restoration_image_comment')570 list_display_links = ('project_name', )571 search_fields = ('project_name', )572admin.site.register( SiteRestorationImage, SiteRestorationImageAdmin)573class InstallationRooftopImageAdmin(admin.ModelAdmin):574 list_display = ('id', 'project_name','team_task_id','start_date','end_date','engineers', 'names_of_engineers','raise_flag','hacking_existing_columns_image','formwork_columns_concrete_pour_curing_image','delivery_to_site_image','lifting_hoisting_freeissue_image','fence_installation_image','site_restoration_image','installation_rooftop_image_comment')575 list_display_links = ('project_name', )576 search_fields = ('project_name', )...

Full Screen

Full Screen

codegen.py

Source:codegen.py Github

copy

Full Screen

1import argparse2import os3from collections import deque4from jinja2 import Template5from sidefridge.scripts import ScriptsDetector, SUPPORTED_DIRECTORIES6from sidefridge.utils import print_logger7TEMPLATE_DIRECTORY_CONFIG_MAP = """8apiVersion: v19kind: ConfigMap10metadata:11 name: {{project_name}}-{{container_name}}-config-{{hook_name}}12 namespace: {{namespace}}13data:14{% for file_name in content_data['file_names'] -%}15{{ file_name | indent(2, True) }}: |16{% for line in content_data['file_content'][file_name] -%}17{{ line | indent(4, True) }}18{%- endfor %}19{%endfor %}20"""[1:-1] # strip first and last '\n'21TEMPLATE_SERVICE_ACCOUNT_NAMES_VOLUMES_PARTIAL = """22serviceAccountName: {{project_name}}-full-access-service-account23volumes:24{% for hook_name in hooks_data -%}25 {{ ("- name: {project_name}-{container_name}-config-{hook_name}-volume".format(project_name=project_name, container_name=container_name, hook_name=hook_name)) | indent(2, True) }}26 configMap:27 name: {{project_name}}-{{container_name}}-config-{{hook_name}}28 defaultMode: 074429 items:30{% for script in hooks_data[hook_name] -%}31{{ ("- key: %s" % script) | indent(8, True) }}32{{ (" path: %s" % script) | indent(8, True) }}33{% endfor %}34{%- endfor %}35"""[1:-1] # strip first and last '\n'36TEMPLATE_VOLUME_MOUNTS_PARTIAL = """37volumeMounts:38{% for script_path, hook_name in content_data -%}39{{"- mountPath: {script_path}".format(script_path=script_path) | indent(2, True)}}40{{" name: {project_name}-{container_name}-config-{hook_name}-volume".format(project_name=project_name, container_name=container_name, hook_name=hook_name) | indent(2, True)}}41{% endfor %}42"""[1:-1] # strip first and last '\n'43TEMPLATE_SERVICE_ACCOUNT_ROLE_ROLE_BINDING = """44apiVersion: v145kind: ServiceAccount46metadata:47 name: {{project_name}}-full-access-service-account48 namespace: {{namespace}}49---50kind: Role51apiVersion: rbac.authorization.k8s.io/v1beta152metadata:53 name: {{project_name}}-full-access-role54 namespace: {{namespace}}55rules:56 - apiGroups: ["", "extensions", "apps"]57 resources: ["*"]58 verbs: ["*"]59 - apiGroups: ["batch"]60 resources:61 - jobs62 - cronjobs63 verbs: ["*"]64---65kind: RoleBinding66apiVersion: rbac.authorization.k8s.io/v1beta167metadata:68 name: {{project_name}}-full-access-role-binding69 namespace: {{namespace}}70subjects:71 - kind: ServiceAccount72 name: {{project_name}}-full-access-service-account73 namespace: {{namespace}}74roleRef:75 apiGroup: rbac.authorization.k8s.io76 kind: Role77 name: {{project_name}}-full-access-role78"""[1:-1] # strip first and last '\n'79def render_template(template, values):80 template = Template(template)81 return template.render(**values)82def render_config_map(namespace, project_name, container_name, hook_name, content_data):83 return render_template(84 template=TEMPLATE_DIRECTORY_CONFIG_MAP,85 values=dict(86 namespace=namespace,87 project_name=project_name,88 container_name=container_name,89 hook_name=hook_name,90 content_data=content_data91 )92 )93def render_service_account_name_volumes_partial(scripts_detector, namespace, project_name, container_name):94 hooks_data = dict()95 for hook_name in SUPPORTED_DIRECTORIES:96 hooks_data[hook_name] = []97 for file_path in getattr(scripts_detector, hook_name, []):98 key = get_script_name_from_path(file_path, hook_name)99 hooks_data[hook_name].append(key)100 return render_template(101 template=TEMPLATE_SERVICE_ACCOUNT_NAMES_VOLUMES_PARTIAL,102 values=dict(103 namespace=namespace,104 project_name=project_name,105 container_name=container_name,106 hooks_data=hooks_data,107 )108 )109def render_volume_mounts_partial(namespace, project_name, container_name, container_scripts_path):110 content_data = []111 for hook_name in SUPPORTED_DIRECTORIES:112 script_path = os.path.join(container_scripts_path, hook_name)113 content_data.append((script_path, hook_name))114 return render_template(115 template=TEMPLATE_VOLUME_MOUNTS_PARTIAL,116 values=dict(117 namespace=namespace,118 project_name=project_name,119 container_name=container_name,120 content_data=content_data,121 )122 )123def get_file_content(file_path):124 file_content = deque()125 with open(file_path, 'r') as f:126 for line in f:127 file_content.append(line)128 return file_content129def get_script_name_from_path(file_path, hook_name):130 return file_path.split(hook_name)[-1][1:]131def generate_config_map_for_hook(scripts_detector, namespace, project_name, container_name, hook_name):132 content_data = dict(file_names=[], file_content={})133 for file_path in getattr(scripts_detector, hook_name, []):134 key = get_script_name_from_path(file_path, hook_name)135 content_data['file_names'].append(key)136 content_data['file_content'][key] = get_file_content(file_path)137 rendered_template = render_config_map(138 namespace=namespace,139 project_name=project_name,140 container_name=container_name,141 hook_name=hook_name,142 content_data=content_data143 )144 return rendered_template145def assemble_config_yaml(scripts_detector, namespace, project_name, container_name, output_path):146 results = []147 for hook_name in SUPPORTED_DIRECTORIES:148 hook_config_yaml = generate_config_map_for_hook(149 scripts_detector=scripts_detector,150 namespace=namespace,151 project_name=project_name,152 container_name=container_name,153 hook_name=hook_name154 )155 results.append(hook_config_yaml)156 file_content = "---\n".join(results)157 with open(os.path.join(output_path, '%s-config-maps.yaml' % project_name), 'w') as f:158 f.write(file_content)159def assemble_service_account_name_volumes_partial(scripts_detector, namespace, project_name, container_name, output_path):160 rendered_yaml = render_service_account_name_volumes_partial(161 scripts_detector=scripts_detector,162 namespace=namespace,163 project_name=project_name,164 container_name=container_name165 )166 with open(os.path.join(output_path, '%s-partial_service_account_name_volumes.yaml' % project_name), 'w') as f:167 f.write(rendered_yaml)168def assemble_volume_mounts_partial(namespace, project_name, container_name, output_path, container_scripts_path):169 rendered_yaml = render_volume_mounts_partial(170 namespace=namespace,171 project_name=project_name,172 container_name=container_name,173 container_scripts_path=container_scripts_path174 )175 with open(os.path.join(output_path, '%s-partial_volume_mounts.yaml' % project_name), 'w') as f:176 f.write(rendered_yaml)177def assemble_service_account_role_role_binding(namespace, project_name, output_path):178 rendered_yaml = render_template(179 template=TEMPLATE_SERVICE_ACCOUNT_ROLE_ROLE_BINDING,180 values=dict(181 namespace=namespace,182 project_name=project_name,183 )184 )185 with open(os.path.join(output_path, '%s-accounts.yaml' % project_name), 'w') as f:186 f.write(rendered_yaml)187def main():188 """ Generates all needed configurations for k8s after providing a scripts directory and some other parameters """189 parser = argparse.ArgumentParser(190 description='Tool for running and initializing backup container'191 )192 parser.add_argument(193 'namespace', type=str,194 help='the k8s namespace'195 )196 parser.add_argument(197 'project_name', type=str,198 help='the current project name'199 )200 parser.add_argument(201 'container_name', type=str,202 help='container name where volumeMounts and volumes are to be used'203 )204 parser.add_argument(205 'in_dir', type=str,206 help='path to your directory containing the hooks'207 )208 parser.add_argument(209 'out_dir', type=str,210 help='directory for k8s configuration file output'211 )212 parser.add_argument(213 '-csp', '--container-scripts-path', default='/scripts',214 help='path to scripts folder inside the container, default /scripts'215 )216 arguments = parser.parse_args()217 # check if provided directory exists218 if not os.path.isdir(arguments.in_dir):219 print_logger("The following path '%s' is not a valid directory" % arguments.in_dir)220 exit(1)221 # check if provided directory exists222 if not os.path.isdir(arguments.out_dir):223 print_logger("The following path '%s' is not a valid directory" % arguments.out_dir)224 exit(1)225 scripts_detector = ScriptsDetector(arguments.in_dir)226 # store yaml files in output directory227 assemble_config_yaml(228 scripts_detector=scripts_detector,229 namespace=arguments.namespace,230 project_name=arguments.project_name,231 container_name=arguments.container_name,232 output_path=arguments.out_dir233 )234 assemble_service_account_name_volumes_partial(235 scripts_detector=scripts_detector,236 namespace=arguments.namespace,237 project_name=arguments.project_name,238 container_name=arguments.container_name,239 output_path=arguments.out_dir240 )241 assemble_volume_mounts_partial(242 namespace=arguments.namespace,243 project_name=arguments.project_name,244 container_name=arguments.container_name,245 output_path=arguments.out_dir,246 container_scripts_path=arguments.container_scripts_path247 )248 assemble_service_account_role_role_binding(249 namespace=arguments.namespace,250 project_name=arguments.project_name,251 output_path=arguments.out_dir252 )253if __name__ == '__main__':...

Full Screen

Full Screen

fabfile.py

Source:fabfile.py Github

copy

Full Screen

1import os.path2from fabric.api import *3env.project_name = os.path.split(os.path.dirname(os.path.abspath(__file__)))[-1]4env.production = False5def staging():6 env.hosts = ['s5.wservices.ch']7 env.user = 'philippbosch'8def production():9 raise NotImplemented10def deploy():11 if env.production:12 input = prompt('Are you sure you want to deploy to the production server?', default="n", validate=r'^[yYnN]$')13 if input not in ['y','Y']:14 exit()15 run('export WORKON_HOME=$HOME/.virtualenvs && source $HOME/bin/virtualenvwrapper_bashrc && workon %(project_name)s && cd ~/%(project_name)s && git pull origin master && ./manage.py migrate && ./manage.py syncdb && ~/init/%(project_name)s restart' % { 'project_name': env.project_name })16def install_requirements():17 run('export WORKON_HOME=$HOME/.virtualenvs && source $HOME/bin/virtualenvwrapper_bashrc && workon %(project_name)s && cd ~/%(project_name)s && pip install -r requirements.txt && ~/init/%(project_name)s restart' % { 'project_name': env.project_name })18def get_media():19 run('cd %(project_name)s/media && tar -cvzf media.tar.gz uploads cms_page_media' % { 'project_name': env.project_name })20 get('%(project_name)s/media/media.tar.gz' % { 'project_name': env.project_name }, 'media.tar.gz')21 run('rm %(project_name)s/media/media.tar.gz' % { 'project_name': env.project_name })22def get_dump():23 run('cd %(project_name)s && mysqldump %(user)s_%(project_name)s > %(project_name)s.sql' % { 'project_name': env.project_name, 'user': env.user })24 get('%(project_name)s/%(project_name)s.sql' % { 'project_name': env.project_name }, '%(project_name)s.sql' % { 'project_name': env.project_name })25 run('rm %(project_name)s/%(project_name)s.sql' % { 'project_name': env.project_name })26 27 input = prompt('Import dump into database?', default="y", validate=r'^[yYnN]$')28 if input in ['y','Y']:29 # quick & dirty: just take the first host and ignore others that might exist30 local('mysql %(project_name)s < %(project_name)s.sql.%(hostname)s' % { 'project_name': env.project_name, 'hostname': env.hosts[0] })...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run dbt-osmosis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful