@staff_member_required
def dashboard(request, template_name=u'admin/dashboard.html'):
 profile = Profile.objects.get_or_create(user=request.user)[0]
 if (profile.extra_data is None):
  profile.extra_data = {}
  profile.save(update_fields=(u'extra_data',))
 profile_data = profile.extra_data
 selected_primary_widgets = []
 unselected_primary_widgets = []
 primary_widget_selections = profile_data.get(u'primary_widget_selections')
 if primary_widget_selections:
  for p in primary_widgets:
   if (primary_widget_selections[p.widget_id] == u'1'):
    selected_primary_widgets.append(p)
   else:
    unselected_primary_widgets.append(p)
 else:
  selected_primary_widgets = primary_widgets
  unselected_primary_widgets = None
 selected_secondary_widgets = []
 unselected_secondary_widgets = []
 secondary_widget_selections = profile_data.get(u'secondary_widget_selections')
 if secondary_widget_selections:
  for s in secondary_widgets:
   if (secondary_widget_selections[s.widget_id] == u'1'):
    selected_secondary_widgets.append(s)
   else:
    unselected_secondary_widgets.append(s)
 else:
  selected_secondary_widgets = secondary_widgets
  unselected_secondary_widgets = None
 primary_widget_positions = profile_data.get(u'primary_widget_positions')
 if primary_widget_positions:
  sorted_primary_widgets = sorted(selected_primary_widgets, key=(lambda y: (primary_widget_positions[y.widget_id] or len(primary_widget_positions))))
 else:
  sorted_primary_widgets = selected_primary_widgets
 secondary_widget_positions = profile_data.get(u'secondary_widget_positions')
 if secondary_widget_positions:
  sorted_secondary_widgets = sorted(selected_secondary_widgets, key=(lambda y: (secondary_widget_positions[y.widget_id] or len(secondary_widget_positions))))
 else:
  sorted_secondary_widgets = selected_secondary_widgets
 return render_to_response(template_name, RequestContext(request, {u'primary_widgets': primary_widgets, u'root_path': (settings.SITE_ROOT + u'admin/db/'), u'secondary_widgets': secondary_widgets, u'selected_primary_widgets': sorted_primary_widgets, u'selected_secondary_widgets': sorted_secondary_widgets, u'support_data': serialize_support_data(request, True), u'title': _(u'Admin Dashboard'), u'unselected_primary_widgets': unselected_primary_widgets, u'unselected_secondary_widgets': unselected_secondary_widgets}))

@ staff_member_required def dashboard ( request , template_name = u'admin/dashboard.html' ) : profile = Profile . objects . get_or_create ( user = request . user ) [ 0 ] if ( profile . extra_data is None ) : profile . extra_data = { } profile . save ( update_fields = ( u'extra_data' , ) ) profile_data = profile . extra_data selected_primary_widgets = [ ] unselected_primary_widgets = [ ] primary_widget_selections = profile_data . get ( u'primary_widget_selections' ) if primary_widget_selections : for p in primary_widgets : if ( primary_widget_selections [ p . widget_id ] == u'1' ) : selected_primary_widgets . append ( p ) else : unselected_primary_widgets . append ( p ) else : selected_primary_widgets = primary_widgets unselected_primary_widgets = None selected_secondary_widgets = [ ] unselected_secondary_widgets = [ ] secondary_widget_selections = profile_data . get ( u'secondary_widget_selections' ) if secondary_widget_selections : for s in secondary_widgets : if ( secondary_widget_selections [ s . widget_id ] == u'1' ) : selected_secondary_widgets . append ( s ) else : unselected_secondary_widgets . append ( s ) else : selected_secondary_widgets = secondary_widgets unselected_secondary_widgets = None primary_widget_positions = profile_data . get ( u'primary_widget_positions' ) if primary_widget_positions : sorted_primary_widgets = sorted ( selected_primary_widgets , key = ( lambda y : ( primary_widget_positions [ y . widget_id ] or len ( primary_widget_positions ) ) ) ) else : sorted_primary_widgets = selected_primary_widgets secondary_widget_positions = profile_data . get ( u'secondary_widget_positions' ) if secondary_widget_positions : sorted_secondary_widgets = sorted ( selected_secondary_widgets , key = ( lambda y : ( secondary_widget_positions [ y . widget_id ] or len ( secondary_widget_positions ) ) ) ) else : sorted_secondary_widgets = selected_secondary_widgets return render_to_response ( template_name , RequestContext ( request , { u'primary_widgets' : primary_widgets , u'root_path' : ( settings . SITE_ROOT + u'admin/db/' ) , u'secondary_widgets' : secondary_widgets , u'selected_primary_widgets' : sorted_primary_widgets , u'selected_secondary_widgets' : sorted_secondary_widgets , u'support_data' : serialize_support_data ( request , True ) , u'title' : _ ( u'Admin Dashboard' ) , u'unselected_primary_widgets' : unselected_primary_widgets , u'unselected_secondary_widgets' : unselected_secondary_widgets } ) )
return the users dashboard web page .