コード例 #1
0
ファイル: views.py プロジェクト: 18F/foia-hub
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
            })
コード例 #2
0
ファイル: views.py プロジェクト: MattTheRed/foia-hub
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))
コード例 #3
0
ファイル: views.py プロジェクト: isabella232/2015-foia-hub
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
    })
コード例 #4
0
ファイル: views.py プロジェクト: 18F/foia-hub
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})
コード例 #5
0
ファイル: views.py プロジェクト: 18F/foia-hub
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
コード例 #6
0
ファイル: views.py プロジェクト: MattTheRed/foia-hub
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))
コード例 #7
0
ファイル: views.py プロジェクト: isabella232/2015-foia-hub
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
コード例 #8
0
ファイル: views.py プロジェクト: isabella232/2015-foia-hub
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
        })
コード例 #9
0
ファイル: urls.py プロジェクト: MattTheRed/foia-hub
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:
コード例 #10
0
ファイル: urls.py プロジェクト: MattTheRed/foia-hub
    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