Skip to content

Instantly share code, notes, and snippets.

@arjunnambiartc
Last active October 20, 2015 05:37
Show Gist options
  • Save arjunnambiartc/9a26bae7a7a84e609b03 to your computer and use it in GitHub Desktop.
Save arjunnambiartc/9a26bae7a7a84e609b03 to your computer and use it in GitHub Desktop.
adminx.py for jericho
import xadmin
from xadmin import views
from models import Sheet1, Change, MyChange
from xadmin.layout import *
class BaseSetting(object):
enable_themes = False
use_bootswatch = False
show_bookmarks = False
xadmin.site.register(views.BaseAdminView, BaseSetting)
class GlobalSetting(object):
global_search_models = [Change, Sheet1]
global_models_icon = {
Change: 'cog', Sheet1: 'calendar'
}
site_title = "Jericho"
xadmin.site.register(views.CommAdminView, GlobalSetting)
class SheetAdmin(object):
search_fields = ('Year',)
list_display = ('Name', 'Year', 'Start_Date', 'End_Date')
refresh_times = (3, 5)
show_bookmarks = False
model_icon = 'globe'
wizard_form_list = [
('First\'s Form', ('Name', 'Year')),
('Second Form', ('Start_Date', 'End_Date'))
]
reversion_enable = True
xadmin.site.register(Sheet1, SheetAdmin)
class ChangeForm(object):
class Meta:
widgets = {
'User_bridge_details': {'class': 'span5'},
'Plan': {'class': 'span18'}
}
class ChangeAdmin(object):
search_fields = ('RFC', 'Plan_Owner')
list_display = ('Reference', 'Sheet', 'Task', 'Ticket', 'Date_of_Request', 'BDD',
'Assigned_group', 'Description', 'Impacted_users', 'User_email_id', 'Impacted_region_types',
'Change_owner', 'Change_ow_assgn_date', 'Change_designer', 'Change_de_assgn_date', 'User_req_comp',
'Date_inf_rec', 'Device_impacted', 'Env',
'RFC', 'RFC_type', 'RFC_status', 'Risk', 'Corp_env', 'Staging',
'Design_status', 'Design_num', 'Peer_review_status', 'User_testing', 'User_bridge',
'Meeting_invite', 'Time_based', 'RFC_Start', 'RFC_End', 'Change_implementer', 'Start_notification',
'End_notification', 'Change_status', 'RFC_closure', 'Change_validation','Ticket_closure')
list_filter = ('Reference', 'Sheet', 'Task', 'Ticket', 'Tool', 'Date_of_Request', 'BDD', 'Assigned_group',
'Description', 'Impacted_users', 'User_email_id', 'Impacted_region_types', 'Change_owner',
'Change_ow_assgn_date', 'Change_designer', 'Change_de_assgn_date', 'User_req_comp', 'Date_inf_rec',
'Device_impacted', 'Env', 'RFC', 'RFC_type', 'RFC_status', 'Risk', 'Corp_env', 'Staging',
'Design_status', 'Design_num', 'Peer_review_status', 'User_testing', 'User_bridge',
'Meeting_invite', 'Time_based', 'RFC_Start', 'RFC_End', 'Change_implementer', 'Start_notification',
'End_notification', 'RFC_closure', 'Change_validation', 'Ticket_closure')
list_editable = ('Reference', 'Sheet', 'Task', 'Ticket', 'Tool', 'Date_of_Request', 'BDD', 'Assigned_group',
'Description', 'Impacted_users', 'User_email_id', 'Impacted_region_types', 'Change_owner',
'Change_ow_assgn_date', 'Change_designer', 'Change_de_assgn_date', 'User_req_comp', 'Date_inf_rec',
'Device_impacted', 'Env', 'RFC', 'RFC_type', 'RFC_status', 'Risk', 'Corp_env', 'Staging',
'Design_status', 'Design_num', 'Peer_review_status', 'User_testing', 'User_bridge',
'Meeting_invite', 'Time_based', 'RFC_Start', 'RFC_End', 'Change_implementer', 'Start_notification',
'End_notification', 'RFC_closure', 'Change_validation', 'Ticket_closure')
show_bookmarks = False
refresh_times = (180, 300)
model_icon = 'flag'
form_layout = (
TabHolder(
Tab('Change',
Fieldset('Status of the Change',
'Change_status',
),
Fieldset('Ticket Information',
'Reference', 'Sheet', 'Task', 'Ticket', 'Tool', 'Date_of_Request',
'BDD', 'Assigned_group', 'Description', 'Impacted_users', 'User_email_id',
'Impacted_region_types',
),
Fieldset('Change Assignment',
'Change_owner', 'Change_ow_assgn_date', 'Change_designer',
'Change_de_assgn_date',
),
Fieldset('Intregity of Input',
'User_req_comp', 'Date_inf_rec',
),
Fieldset('CMDB',
'Device_impacted', 'Env',
),
Fieldset('Communications',
'Mon_comm', 'Tue_comm', 'Wed_comm', 'Thu_comm', 'Fri_comm',
'Sat_comm', 'Sun_comm',
),
Fieldset('RFC Details',
'RFC', 'RFC_type', 'RFC_status', 'Risk',
),
Fieldset('Design & Peer Review',
'Corp_env', 'Staging', 'Design_status', 'Design_num', 'Peer_review_status',
),
Fieldset('User Testing',
'User_testing', 'User_bridge', 'User_bridge_details', 'Meeting_invite',
),
Fieldset('Weekend Tracking',
'Time_based', 'RFC_Start', 'RFC_End', 'Change_implementer', 'Start_notification',
'End_notification', 'RFC_closure', 'Change_validation', 'Ticket_closure',
),
),
Tab('Plan',
Fieldset('Attach Plan',
'Plan',
),
)
),
)
def queryset(self):
return Change.objects.exclude(Change_status='3')
def result_row(self, obj):
row = super(ChangeAdmin, self).result_row(obj)
class_map = {
2: 'warning',
3: 'success',
4: 'danger',
5: 'danger',
6: 'danger',
7: 'danger',
}
row['css_class'] = class_map.get(obj.Change_status)
return row
reversion_enable = True
xadmin.site.register(Change, ChangeAdmin)
class MyChangeAdmin(object):
search_fields = ('RFC', 'Plan_Owner')
list_display = ('Reference', 'Sheet', 'Task', 'Ticket', 'Date_of_Request', 'BDD',
'Assigned_group', 'Description', 'Impacted_users', 'User_email_id', 'Impacted_region_types',
'Change_owner', 'Change_ow_assgn_date', 'Change_designer', 'Change_de_assgn_date', 'User_req_comp',
'Date_inf_rec', 'Device_impacted', 'Env',
'RFC', 'RFC_type', 'RFC_status', 'Risk', 'Corp_env', 'Staging',
'Design_status', 'Design_num', 'Peer_review_status', 'User_testing', 'User_bridge',
'Meeting_invite', 'Time_based', 'RFC_Start', 'RFC_End', 'Change_implementer', 'Start_notification',
'End_notification', 'Change_status', 'RFC_closure', 'Change_validation','Ticket_closure')
list_filter = ('Reference', 'Sheet', 'Task', 'Ticket', 'Tool', 'Date_of_Request', 'BDD', 'Assigned_group',
'Description', 'Impacted_users', 'User_email_id', 'Impacted_region_types', 'Change_owner',
'Change_ow_assgn_date', 'Change_designer', 'Change_de_assgn_date', 'User_req_comp', 'Date_inf_rec',
'Device_impacted', 'Env', 'RFC', 'RFC_type', 'RFC_status', 'Risk', 'Corp_env', 'Staging',
'Design_status', 'Design_num', 'Peer_review_status', 'User_testing', 'User_bridge',
'Meeting_invite', 'Time_based', 'RFC_Start', 'RFC_End', 'Change_implementer', 'Start_notification',
'End_notification', 'RFC_closure', 'Change_validation', 'Ticket_closure')
list_editable = ('Reference', 'Sheet', 'Task', 'Ticket', 'Tool', 'Date_of_Request', 'BDD', 'Assigned_group',
'Description', 'Impacted_users', 'User_email_id', 'Impacted_region_types', 'Change_owner',
'Change_ow_assgn_date', 'Change_designer', 'Change_de_assgn_date', 'User_req_comp', 'Date_inf_rec',
'Device_impacted', 'Env', 'RFC', 'RFC_type', 'RFC_status', 'Risk', 'Corp_env', 'Staging',
'Design_status', 'Design_num', 'Peer_review_status', 'User_testing', 'User_bridge',
'Meeting_invite', 'Time_based', 'RFC_Start', 'RFC_End', 'Change_implementer', 'Start_notification',
'End_notification', 'RFC_closure', 'Change_validation', 'Ticket_closure')
show_bookmarks = False
refresh_times = (180, 300)
model_icon = 'flag'
form_layout = (
TabHolder(
Tab('Change',
Fieldset('Status of the Change',
'Change_status',
),
Fieldset('Ticket Information',
'Reference', 'Sheet', 'Task', 'Ticket', 'Tool', 'Date_of_Request',
'BDD', 'Assigned_group', 'Description', 'Impacted_users', 'User_email_id',
'Impacted_region_types',
),
Fieldset('Change Assignment',
'Change_owner', 'Change_ow_assgn_date', 'Change_designer',
'Change_de_assgn_date',
),
Fieldset('Intregity of Input',
'User_req_comp', 'Date_inf_rec',
),
Fieldset('CMDB',
'Device_impacted', 'Env',
),
Fieldset('Communications',
'Mon_comm', 'Tue_comm', 'Wed_comm', 'Thu_comm', 'Fri_comm',
'Sat_comm', 'Sun_comm',
),
Fieldset('RFC Details',
'RFC', 'RFC_type', 'RFC_status', 'Risk',
),
Fieldset('Design & Peer Review',
'Corp_env', 'Staging', 'Design_status', 'Design_num', 'Peer_review_status',
),
Fieldset('User Testing',
'User_testing', 'User_bridge', 'User_bridge_details', 'Meeting_invite',
),
Fieldset('Weekend Tracking',
'Time_based', 'RFC_Start', 'RFC_End', 'Change_implementer', 'Start_notification',
'End_notification', 'RFC_closure', 'Change_validation', 'Ticket_closure',
),
),
Tab('Plan',
Fieldset('Attach Plan',
'Plan',
),
)
),
)
def result_row(self, obj):
row = super(MyChangeAdmin, self).result_row(obj)
class_map = {
2: 'warning',
3: 'success',
4: 'danger',
5: 'danger',
6: 'danger',
7: 'danger',
}
row['css_class'] = class_map.get(obj.Change_status)
return row
def queryset(self):
return MyChange.objects.filter(Change_status='3')
reversion_enable = True
xadmin.site.register(MyChange, MyChangeAdmin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment