@@ -60,6 +60,14 @@ class BrandChangeForm(PermissionRequiredMixin, UpdateView):
6060 raise_exception = True
6161 model = Brand
6262 form_class = BrandForm
63+ template_name = 'brands/detail.html'
64+
65+ def get_context_data (self , ** kwargs ):
66+ context = super ().get_context_data (** kwargs )
67+ context ['change_form' ] = context .get ('form' )
68+ brand_obj = self .get_object ()
69+ context ['brand' ] = model_to_dict (brand_obj )
70+ return context
6371
6472 def get_object (self , queryset = None ):
6573 brand_id = self .kwargs .get ('brand_id' )
@@ -81,13 +89,17 @@ def post(self, request, *args, **kwargs):
8189 view = BrandChangeForm .as_view ()
8290 primary_color = request .POST .get ('primary_color' )
8391 secondary_color = request .POST .get ('secondary_color' )
92+ background_color = request .POST .get ('background_color' )
8493
8594 if not is_a11y (primary_color ):
8695 messages .warning (request , """The selected primary color is not a11y compliant.
8796 For more information, visit https://color.a11y.com/""" )
8897 if not is_a11y (secondary_color ):
8998 messages .warning (request , """The selected secondary color is not a11y compliant.
9099 For more information, visit https://color.a11y.com/""" )
100+ if background_color and not is_a11y (background_color ):
101+ messages .warning (request , """The selected background color is not a11y compliant.
102+ For more information, visit https://color.a11y.com/""" )
91103 return view (request , * args , ** kwargs )
92104
93105
@@ -109,11 +121,15 @@ def get_context_data(self, *args, **kwargs):
109121 def post (self , request , * args , ** kwargs ):
110122 primary_color = request .POST .get ('primary_color' )
111123 secondary_color = request .POST .get ('secondary_color' )
124+ background_color = request .POST .get ('background_color' )
112125
113126 if not is_a11y (primary_color ):
114127 messages .warning (request , """The selected primary color is not a11y compliant.
115128 For more information, visit https://color.a11y.com/""" )
116129 if not is_a11y (secondary_color ):
117130 messages .warning (request , """The selected secondary color is not a11y compliant.
118131 For more information, visit https://color.a11y.com/""" )
132+ if background_color and not is_a11y (background_color ):
133+ messages .warning (request , """The selected background color is not a11y compliant.
134+ For more information, visit https://color.a11y.com/""" )
119135 return super ().post (request , * args , ** kwargs )
0 commit comments