Commit 4ec3535d authored by Patrick's avatar Patrick

Hide represent_this_buyinggroup on admin customer/producer when those doesn't...

Hide represent_this_buyinggroup on admin customer/producer when those doesn't represent_this_buyinggroup
parent e3a9bdfe
......@@ -311,7 +311,7 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin):
else:
fields_basic += [
('get_admin_balance', 'price_list_multiplier', 'get_admin_date_balance'),
('may_order', 'is_active', 'represent_this_buyinggroup'),
('may_order', 'is_active'),
]
else:
fields_basic += [
......@@ -336,12 +336,20 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin):
def get_readonly_fields(self, request, customer=None):
if customer is not None:
return [
'get_admin_date_balance', 'get_admin_balance',
'represent_this_buyinggroup', 'get_last_login',
'get_date_joined', 'get_participation', 'get_purchase',
'get_last_membership_fee', 'get_last_membership_fee_date'
]
if customer.represent_this_buyinggroup:
return [
'get_admin_date_balance', 'get_admin_balance',
'represent_this_buyinggroup', 'get_last_login',
'get_date_joined', 'get_participation', 'get_purchase',
'get_last_membership_fee', 'get_last_membership_fee_date'
]
else:
return [
'get_admin_date_balance', 'get_admin_balance',
'get_last_login',
'get_date_joined', 'get_participation', 'get_purchase',
'get_last_membership_fee', 'get_last_membership_fee_date'
]
else:
return [
'represent_this_buyinggroup', 'get_last_login',
......
......@@ -290,8 +290,11 @@ class ProducerAdmin(ImportExportMixin, admin.ModelAdmin):
'memo',
'reference_site',
'web_services_activated',
'represent_this_buyinggroup',
]
if producer is not None and producer.represent_this_buyinggroup:
fields_advanced += [
'represent_this_buyinggroup'
]
fieldsets = (
(None, {'fields': fields_basic}),
(_('Advanced options'), {'classes': ('collapse',), 'fields': fields_advanced})
......@@ -300,10 +303,14 @@ class ProducerAdmin(ImportExportMixin, admin.ModelAdmin):
def get_readonly_fields(self, request, producer=None):
if producer is not None:
return ['web_services_activated', 'represent_this_buyinggroup', 'get_admin_date_balance',
'get_admin_balance']
if producer.represent_this_buyinggroup:
return ['web_services_activated', 'represent_this_buyinggroup', 'get_admin_date_balance',
'get_admin_balance']
else:
return ['web_services_activated', 'get_admin_date_balance',
'get_admin_balance']
else:
return ['web_services_activated', 'represent_this_buyinggroup']
return ['web_services_activated']
def save_model(self, request, producer, form, change):
producer.web_services_activated, drop1, drop2 = producer_web_services_activated(producer.reference_site)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment