def get_items(request, section, module, accessible, path, can_edit, instructor_link, user_profile): items = dict(section=section, module=module, accessible=accessible, needs_submit=needs_submit(section), is_submitted=submitted(section, request.user), modules=primary_nav_sections(user_profile), root=section.hierarchy.get_root(), instructor_link=instructor_link, can_edit=can_edit, allow_redo=allow_redo(section), next_unlocked=is_section_unlocked(user_profile, section.get_next())) if accessible and path.startswith('map'): items['career_stages'] = CAREER_STAGE_CHOICES items['clinical_fields'] = \ ClinicalField.objects.all().distinct().order_by('name') items['teaching_responsibilities'] = \ TeachingResponsibility.objects.all().order_by('name') items['paid_time_commitments'] = TimeCommitment.objects.all() items['volunteer_time_commitments'] = TimeCommitment.objects.all() items['trainee_types'] = PrimaryTraineesType.objects.all() return items
def edit_page(request, path): section = get_section_from_path(path) user_profile = get_or_create_profile(user=request.user, section=section) return dict(section=section, module=get_module(section), modules=primary_nav_sections(user_profile), root=section.hierarchy.get_root(), can_edit=True)
def profile(request, educator_id): section = get_section_from_path("map/") user_profile = get_or_create_profile(user=request.user, section=section) if not is_section_unlocked(user_profile, section): return HttpResponseRedirect("/") educator = get_object_or_404(DentalEducator, id=educator_id) return dict(educator=educator, module=get_module(section), modules=primary_nav_sections(user_profile), root=section.hierarchy.get_root())
def index(request): profile, created = UserProfile.objects.get_or_create(user=request.user) return render(request, 'main/index.html', {'modules': primary_nav_sections(profile)})
def page(request, path): section = get_section_from_path(path) hierarchy = section.hierarchy module = get_module(section) user_profile = get_or_create_profile(user=request.user, section=section) accessible = is_section_unlocked(user_profile, section) if accessible: user_profile.save_visit(section) can_edit = can_user_edit(request) first_leaf = hierarchy.get_first_leaf(section) ancestors = first_leaf.get_ancestors() # Skip to the first leaf, make sure to mark these sections as visited if (section != first_leaf): user_profile.save_visits(ancestors) return HttpResponseRedirect(first_leaf.get_absolute_url()) if accessible and request.method == "POST": # user has submitted a form. deal with it if request.POST.get('action', '') == 'reset': section.reset(request.user) return HttpResponseRedirect(section.get_absolute_url()) section.submit(request.POST, request.user) if section.slug == "ce-credit": next_section = section.get_next() if next_section: return HttpResponseRedirect(next_section.get_absolute_url()) else: return HttpResponseRedirect(section.get_absolute_url()) else: instructor_link = has_responses(section) items = dict(section=section, module=module, accessible=accessible, needs_submit=needs_submit(section), is_submitted=submitted(section, request.user), modules=primary_nav_sections(user_profile), root=section.hierarchy.get_root(), instructor_link=instructor_link, can_edit=can_edit, allow_redo=allow_redo(section), next_unlocked=is_section_unlocked(user_profile, section.get_next())) template_name = template_from_path(accessible, path) if accessible and path.startswith('map'): items['career_stages'] = CAREER_STAGE_CHOICES items['clinical_fields'] = \ ClinicalField.objects.all().distinct().order_by('name') items['teaching_responsibilities'] = \ TeachingResponsibility.objects.all().order_by('name') items['paid_time_commitments'] = TimeCommitment.objects.all() items['volunteer_time_commitments'] = TimeCommitment.objects.all() items['trainee_types'] = PrimaryTraineesType.objects.all() return render_to_response(template_name, items, context_instance=RequestContext(request))
def index(request): profile, created = UserProfile.objects.get_or_create(user=request.user) return {'modules': primary_nav_sections(profile)}