How to use has_delete_permission method in Kiwi

Best Python code snippet using Kiwi_python

admin.py

Source:admin.py Github

copy

Full Screen

...17 def get_actions(self, request):18 actions = super(DrugInfoAdmin, self).get_actions(request)19 del actions['delete_selected']20 return actions21 def has_delete_permission(self, request, obj=None):22 return False23class FrequencyAdmin(admin.ModelAdmin):24 list_display = ('number_of_times','active',)25 search_fields = ('number_of_times',)26 def get_actions(self, request):27 actions = super(FrequencyAdmin, self).get_actions(request)28 del actions['delete_selected']29 return actions30 def has_delete_permission(self, request, obj=None):31 return False32class DosageAdmin(admin.ModelAdmin):33 list_display = ('dosage','active',)34 search_fields = ('dosage',)35 def get_actions(self, request):36 actions = super(DosageAdmin, self).get_actions(request)37 del actions['delete_selected']38 return actions39 def has_delete_permission(self, request, obj=None):40 return False41class DirectionsAdmin(admin.ModelAdmin):42 list_display = ('directions','active',)43 search_fields = ('directions',)44 def get_actions(self, request):45 actions = super(DirectionsAdmin, self).get_actions(request)46 del actions['delete_selected']47 return actions48 def has_delete_permission(self, request, obj=None):49 return False50class ICD10Admin(admin.ModelAdmin): 51 list_display = ('ICD10_Chapter','ICD10_Code','ICD10_Name','can_select','status')52 search_fields = ('ICD10_Chapter','ICD10_Code','ICD10_Name',)53 def get_actions(self, request):54 actions = super(ICD10Admin, self).get_actions(request)55 del actions['delete_selected']56 return actions57 def has_delete_permission(self, request, obj=None):58 return False59class InvestigationAdmin(admin.ModelAdmin):60 list_display = ('service_group_name','investigation_name','is_active',)61 search_fields = ('service_group_name','investigation_name','is_active',)62 def get_actions(self, request):63 actions = super(InvestigationAdmin, self).get_actions(request)64 del actions['delete_selected']65 return actions66 def has_delete_permission(self, request, obj=None):67 return False68class PocInfoAdmin(admin.ModelAdmin): 69 list_display = ('visitentityid','entityidec','anmid','level','clientversion','serverversion','visittype','phc','pending','docid',)70 search_fields = ('visitentityid','entityidec','anmid',)71 def get_actions(self, request):72 actions = super(PocInfoAdmin, self).get_actions(request)73 del actions['delete_selected']74 return actions75 def has_delete_permission(self, request, obj=None):76 return False77class UserMaintenanceAdmin(admin.ModelAdmin):78 form = UserMaintenaceForm79 list_display = ('user_id','user_role','name','phone_number','email','villages','active',)80 search_fields = ('user_id',)81 def get_urls(self):82 urls = super(UserMaintenanceAdmin, self).get_urls()83 my_urls = patterns('',84 url(r'add/$', 'Masters.views.adminadd_usermaintenance',name='user_maintenance'),85 url(r'(?P<batch_id>\d+)/$','Masters.views.edit_usermaintenance',name='editusermaintenance'),86 )87 return my_urls + urls88 def get_actions(self, request):89 actions = super(UserMaintenanceAdmin, self).get_actions(request)90 del actions['delete_selected']91 return actions92 def has_delete_permission(self, request, obj=None):93 return False94class CountryAdmin(admin.ModelAdmin):95 list_display=('country_name','country_code','active',)96 search_fields = ('country_name',)97 def get_actions(self, request):98 actions = super(CountryAdmin, self).get_actions(request)99 del actions['delete_selected']100 return actions101 def has_delete_permission(self, request, obj=None):102 return False103class CountyAdmin(admin.ModelAdmin):104 list_display = ('county_name','country_name','active',)105 search_fields = ('county_name',)106 def get_actions(self, request):107 actions = super(CountyAdmin, self).get_actions(request)108 del actions['delete_selected']109 return actions110 def has_delete_permission(self, request, obj=None):111 return False112class DisttabAdmin(admin.ModelAdmin):113 list_display = ('district_name','county_name','country_name','active')114 search_fields = ('district_name',)115 def get_urls(self):116 urls = super(DisttabAdmin, self).get_urls()117 my_urls = patterns('',118 url(r'add/$', 'Masters.views.adminadd_district',name='add_district'),119 url(r'(?P<district_id>\d+)/$','Masters.views.edit_district',name='editdistrict'),120 )121 return my_urls + urls122 def get_actions(self, request):123 actions = super(DisttabAdmin, self).get_actions(request)124 del actions['delete_selected']125 return actions126 def has_delete_permission(self, request, obj=None):127 return False128class SubdistrictTabAdmin(admin.ModelAdmin):129 list_display = ('subdistrict','district','county','country','active',)130 search_fields = ('subdistrict',)131 def get_urls(self):132 urls = super(SubdistrictTabAdmin, self).get_urls()133 my_urls = patterns('',134 url(r'add/$', 'Masters.views.adminadd_subdistrict',name='add_subdistrict'),135 url(r'(?P<subdistrict_id>\d+)/$','Masters.views.edit_subdistrict',name='editsubdistrict'),136 )137 return my_urls + urls138 def get_actions(self, request):139 actions = super(SubdistrictTabAdmin, self).get_actions(request)140 del actions['delete_selected']141 return actions142 def has_delete_permission(self, request, obj=None):143 return False144class LocationTabAdmin(admin.ModelAdmin):145 list_display = ('location','subdistrict','district','county','country','active',)146 search_fields = ('location',)147 def get_urls(self):148 urls = super(LocationTabAdmin, self).get_urls()149 my_urls = patterns('',150 url(r'add/$', 'Masters.views.adminadd_location',name='add_subdistrict'),151 url(r'(?P<loc_id>\d+)/$','Masters.views.edit_location',name='editlocation'),152 )153 return my_urls + urls154 155 def save_model(self, request, obj, form, change):156 # add an additional message157 messages.info(request, "Extra message here.")158 super(LocationTabAdmin, self).save_model(request, obj, form, change)159 def get_actions(self, request):160 actions = super(LocationTabAdmin, self).get_actions(request)161 del actions['delete_selected']162 return actions163 def has_delete_permission(self, request, obj=None):164 return False165class HealthCenterAdmin(admin.ModelAdmin):166 list_display = ('hospital_name','hospital_type','hospital_address','country_name','county_name','district_name','subdistrict_name','parent_hospital','villages','active')167 search_fields = ('hospital_name',)168 def get_urls(self):169 urls = super(HealthCenterAdmin, self).get_urls()170 my_urls = patterns('',171 url(r'add/$', 'Masters.views.admin_hospital',name='hospital'),172 #url(r'gettype/$', 'Masters.views.get_hospital',name='hospital'),173 url(r'(?P<hospital_id>\d+)/$', 'Masters.views.edit_hospital',name='edithospital'),174 )175 return my_urls + urls176 def get_actions(self, request):177 actions = super(HealthCenterAdmin, self).get_actions(request)178 del actions['delete_selected']179 return actions180 def has_delete_permission(self, request, obj=None):181 return False182class AppConfigurationAdmin(admin.ModelAdmin):183 list_display = ('wife_age_min','wife_age_max','husband_age_min','husband_age_max','temperature_units','country_name',)184 search_fields = ('wife_age_min',)185 fieldsets = (186 (None, {187 'fields': ('country_name','temperature_units','escalation_schedule','is_highrisk')188 }),189 ('Wife age', {190 'fields': ('wife_age_min','wife_age_max')191 }),192 ('Husband age', {193 'fields': ('husband_age_min','husband_age_max')194 }),195 )196 def get_actions(self, request):197 actions = super(AppConfigurationAdmin, self).get_actions(request)198 del actions['delete_selected']199 return actions200 def has_delete_permission(self, request, obj=None):201 return False202class FormFieldsAdmin(admin.ModelAdmin):203 list_display = ('form_name','field1','field2','field3','field4','field5','country')204 search_fields = ('form_name',)205 def get_actions(self, request):206 actions = super(FormFieldsAdmin, self).get_actions(request)207 del actions['delete_selected']208 return actions209 def has_delete_permission(self, request, obj=None):210 return False211class AnnualTargetAdmin(admin.ModelAdmin):212 list_display = ('service_provider','indicator','target','start_date','end_date',)213 search_fields = ('service_provider', )214 list_filter = ('indicator',)215 def get_actions(self, request):216 actions = super(AnnualTargetAdmin, self).get_actions(request)217 del actions['delete_selected']218 return actions219 def has_delete_permission(self, request, obj=None):220 return False 221class DimIndicatorAdmin(admin.ModelAdmin):222 list_display = ('indicator',)223 def get_actions(self, request):224 actions = super(DimIndicatorAdmin, self).get_actions(request)225 del actions['delete_selected']226 return actions227 def has_delete_permission(self, request, obj=None):228 return False 229admin.site.register(DrugInfo,DrugInfoAdmin)230admin.site.register(Frequency,FrequencyAdmin)231admin.site.register(Dosage,DosageAdmin)232admin.site.register(Directions,DirectionsAdmin)233admin.site.register(ICD10,ICD10Admin)234admin.site.register(Investigations,InvestigationAdmin)235admin.site.register(PocInfo,PocInfoAdmin)236admin.site.register(UserMasters,UserMaintenanceAdmin)237admin.site.register(CountryTb,CountryAdmin)238admin.site.register(CountyTb,CountyAdmin)239admin.site.register(Disttab,DisttabAdmin)240admin.site.register(SubdistrictTab,SubdistrictTabAdmin)241admin.site.register(LocationTab,LocationTabAdmin)...

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 Kiwi 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