def contact_landing(request, slug): """Principal landing page for agencies and offices.""" if '--' in slug: resource = OfficeResource() else: resource = AgencyResource() data = resource.detail(slug).value if (data['is_a'] == 'agency') and (len(data.get("offices", [])) > 0): return render( request, 'contacts/parent_profile.html', { 'profile': data, 'slug': slug, 'show_webform': settings.SHOW_WEBFORM }) else: return render( request, 'contacts/profile.html', { 'profile': data, 'slug': slug, 'show_webform': settings.SHOW_WEBFORM })
def request_form(request, slug=None): """Request form for an agency or office.""" if '--' in slug: resource = OfficeResource() else: resource = AgencyResource() data = resource.detail(slug).value template = env.get_template('request/form.html') return HttpResponse(template.render(profile=data, slug=slug))
def request_form(request, slug=None): """Request form for an agency or office.""" if '--' in slug: resource = OfficeResource() else: resource = AgencyResource() data = resource.detail(slug).value return render(request, 'request/form.html', { 'profile': data, 'slug': slug })
def request_form(request, slug=None): """Request form for an agency or office.""" if '--' in slug: resource = OfficeResource() else: resource = AgencyResource() data = resource.detail(slug).value return render( request, 'request/form.html', {'profile': data, 'slug': slug})
def get_agency_data(slug): """ Given an agency slug parse through the agency API and collect agency info to populate agency form. """ agency_resource = AgencyResource() agency_data = [transform_data(agency_resource.detail(slug).value)] if agency_data[0].get('offices'): office_resource = OfficeResource() for office in agency_data[0].get('offices'): if '--' in office.get('slug'): office_data = office_resource.detail(office['slug']).value else: office_data = agency_resource.detail(office['slug']).value agency_data.append(transform_data(office_data)) return agency_data
def contact_landing(request, slug): """Principal landing page for agencies and offices.""" if '--' in slug: resource = OfficeResource() else: resource = AgencyResource() data = resource.detail(slug).value if (data['is_a'] == 'agency') and (len(data.get("offices", [])) > 0): template = env.get_template('contacts/parent_profile.html') else: template = env.get_template('contacts/profile.html') return HttpResponse(template.render( profile=data, slug=slug, show_webform=settings.SHOW_WEBFORM))
def contact_landing(request, slug): """Principal landing page for agencies and offices.""" if '--' in slug: resource = OfficeResource() else: resource = AgencyResource() data = resource.detail(slug).value if (data['is_a'] == 'agency') and (len(data.get("offices", [])) > 0): return render(request, 'contacts/parent_profile.html', { 'profile': data, 'slug': slug, 'show_webform': settings.SHOW_WEBFORM }) else: return render(request, 'contacts/profile.html', { 'profile': data, 'slug': slug, 'show_webform': settings.SHOW_WEBFORM })
urlpatterns = patterns( '', url(r'^$', home, name='home'), url(r'^learn/?$', learn, name='learn'), url(r'^about/?$', about, name='about'), url(r'^agencies/?$', agencies, name='agencies'), url(r'^developers/?$', developers, name='developers'), url(r'^contacts/(?P<slug>[-\w]+)/?$', contact_landing, name='contact_landing'), url(r'^request/(?P<slug>[-\w]+)/$', request_form, name='form'), url(r'^request/success/(?P<id>[\d]+)/$', request_success, name='success')) # APIs urlpatterns += patterns( '', url(r'^api/agency/', include(AgencyResource.urls())), url(r'^api/office/', include(OfficeResource.urls())), ) if settings.SHOW_WEBFORM: urlpatterns += patterns( '', url(r'^api/request/', include(FOIARequestResource.urls()))) # Admin admin.autodiscover() urlpatterns += patterns( '', url(r'^admin/', include(admin.site.urls)), ) # For development if settings.DEBUG:
url(r'^$', home, name='home'), url(r'^learn/?$', learn, name='learn'), url(r'^about/?$', about, name='about'), url(r'^agencies/?$', agencies, name='agencies'), url(r'^developers/?$', developers, name='developers'), url(r'^contacts/(?P<slug>[-\w]+)/?$', contact_landing, name='contact_landing'), url(r'^request/(?P<slug>[-\w]+)/$', request_form, name='form'), url(r'^request/success/(?P<id>[\d]+)/$', request_success, name='success') ) # APIs urlpatterns += patterns( '', url(r'^api/agency/', include(AgencyResource.urls())), url(r'^api/office/', include(OfficeResource.urls())), ) if settings.SHOW_WEBFORM: urlpatterns += patterns( '', url(r'^api/request/', include(FOIARequestResource.urls()))) # Admin admin.autodiscover() urlpatterns += patterns( '', url(r'^admin/', include(admin.site.urls)), ) # For development