def widget_select(request):
 profile = Profile.objects.get_or_create(user=request.user)[0]
 profile_data = profile.extra_data
 widget_type = request.POST.get(u'type')
 if (widget_type == u'primary'):
  selections_key = u'primary_widget_selections'
  widgets = primary_widgets
 else:
  selections_key = u'secondary_widget_selections'
  widgets = secondary_widgets
 initial_selections = {}
 for widget in widgets:
  initial_selections[widget.widget_id] = u'1'
 selections = profile_data.setdefault(selections_key, initial_selections)
 for widget in widgets:
  widget_selection = request.POST.get(widget.widget_id)
  if (widget_selection is not None):
   selections[widget.widget_id] = widget_selection
 profile.save()
 return HttpResponse()

def widget_select ( request ) : profile = Profile . objects . get_or_create ( user = request . user ) [ 0 ] profile_data = profile . extra_data widget_type = request . POST . get ( u'type' ) if ( widget_type == u'primary' ) : selections_key = u'primary_widget_selections' widgets = primary_widgets else : selections_key = u'secondary_widget_selections' widgets = secondary_widgets initial_selections = { } for widget in widgets : initial_selections [ widget . widget_id ] = u'1' selections = profile_data . setdefault ( selections_key , initial_selections ) for widget in widgets : widget_selection = request . POST . get ( widget . widget_id ) if ( widget_selection is not None ) : selections [ widget . widget_id ] = widget_selection profile . save ( ) return HttpResponse ( )
handle selection of admin widgets .