def get_menu_dict(request): member = request.user.member next_jobs = [] required_assignments = 0 if member.subscription is not None: partner_assignments = [] for subscription_member in member.subscription.recipients_all: if subscription_member == member: continue partner_assignments.extend( AssignmentDao.assignments_for_member_current_business_year( subscription_member)) userassignments = AssignmentDao.assignments_for_member_current_business_year( member) required_assignments = member.subscription.required_assignments assignmentsrange = list( range( 0, max(required_assignments, len(userassignments) + len(partner_assignments)))) for assignment in AssignmentDao.upcomming_assignments_for_member( member).order_by('job__time'): next_jobs.append(assignment.job) else: assignmentsrange = None partner_assignments = [] userassignments = [] next_jobs = [] userassignments_total = int(sum(a.amount for a in userassignments)) userassignemnts_core = int( sum(a.amount for a in userassignments if a.is_core())) partner_assignments_total = int(sum(a.amount for a in partner_assignments)) partner_assignments_core = int( sum(a.amount for a in partner_assignments if a.is_core())) assignmentsrange = list( range( 0, max(required_assignments, userassignments_total + partner_assignments_total))) depot_admin = DepotDao.depots_for_contact(request.user.member) area_admin = ActivityAreaDao.areas_by_coordinator(request.user.member) menu_dict = { 'user': request.user, 'assignmentsrange': assignmentsrange, 'userassignments_bound': userassignments_total, 'userassignemnts_core_bound': userassignemnts_core, 'partner_assignments_bound': userassignments_total + partner_assignments_total, 'partner_assignments__core_bound': userassignments_total + partner_assignments_core, 'next_jobs': next_jobs, 'can_filter_members': request.user.has_perm('juntagrico.can_filter_members'), 'can_filter_subscriptions': request.user.has_perm('juntagrico.can_filter_subscriptions'), 'can_send_mails': request.user.has_perm('juntagrico.can_send_mails'), 'operation_group': request.user.has_perm('juntagrico.is_operations_group'), 'has_extra_subscriptions': ExtraSubscriptionCategoryDao.all_categories_ordered().count() > 0, 'depot_admin': depot_admin, 'area_admin': area_admin, 'show_core': ActivityAreaDao.all_core_areas().count() > 0, 'show_extras': JobExtraDao.all_job_extras().count() > 0, 'show_deliveries': len( DeliveryDao.deliveries_by_subscription( request.user.member.subscription)) > 0, 'admin_menus': get_admin_menus(), } enrich_menu_dict(request, menu_dict) return menu_dict
def get_menu_dict(request): member = request.user.member next_jobs = JobDao.upcomming_jobs_for_member(member) required_assignments = 0 if member.subscription_current is not None: partner_assignments = [] for subscription_member in member.subscription_current.recipients_all: if subscription_member == member: continue partner_assignments.extend( AssignmentDao.assignments_for_member_current_business_year( subscription_member)) userassignments = AssignmentDao.assignments_for_member_current_business_year( member) required_assignments = member.subscription_current.required_assignments else: partner_assignments = [] userassignments = [] userassignments_total = int(sum(a.amount for a in userassignments)) userassignemnts_core = int( sum(a.amount for a in userassignments if a.is_core())) partner_assignments_total = int(sum(a.amount for a in partner_assignments)) partner_assignments_core = int( sum(a.amount for a in partner_assignments if a.is_core())) assignmentsrange = list( range( 0, max(required_assignments, userassignments_total + partner_assignments_total))) depot_admin = DepotDao.depots_for_contact(request.user.member) area_admin = ActivityAreaDao.areas_by_coordinator(request.user.member) menu_dict = get_page_dict(request) menu_dict.update({ 'user': request.user, 'assignmentsrange': assignmentsrange, 'userassignments_bound': userassignments_total, 'userassignemnts_core_bound': userassignemnts_core, 'partner_assignments_bound': userassignments_total + partner_assignments_total, 'partner_assignments_core_bound': userassignments_total + partner_assignments_core, 'next_jobs': next_jobs, 'can_filter_members': request.user.has_perm('juntagrico.can_filter_members'), 'can_filter_subscriptions': request.user.has_perm('juntagrico.can_filter_subscriptions'), 'can_send_mails': request.user.has_perm('juntagrico.can_send_mails'), 'operation_group': request.user.has_perm('juntagrico.is_operations_group'), 'has_extra_subscriptions': ExtraSubscriptionCategoryDao.all_categories_ordered().count() > 0, 'depot_admin': depot_admin, 'area_admin': area_admin, 'show_core': ActivityAreaDao.all_core_areas().count() > 0, 'requires_core': SubscriptionTypeDao.get_with_core().count() > 0, 'show_extras': JobExtraDao.all_job_extras().count() > 0, 'show_deliveries': len( DeliveryDao.deliveries_by_subscription( request.user.member.subscription_current)) > 0, 'admin_menus': addons.config.get_admin_menus(), 'admin_subscription_menus': addons.config.get_admin_subscription_menu(), 'user_menus': addons.config.get_user_menus(), 'messages': [], }) return menu_dict