From 54b19a1fbb9efef23992faa21a9b183dec8fc2a5 Mon Sep 17 00:00:00 2001 From: Nicolas Joyard <joyard.nicolas@gmail.com> Date: Thu, 2 Jun 2016 08:30:12 +0200 Subject: [PATCH] Remove contact from position page and update test fixtures --- .../content | 2 +- .../content | 2 +- .../content | 2 +- .../content | 2 +- .../content | 2 +- memopol/tests/test_representatives_detail.py | 6 ++++- .../_representative_block.haml | 24 ------------------ .../_representative_contact.haml | 25 +++++++++++++++++++ .../representative_detail.haml | 1 + 9 files changed, 36 insertions(+), 30 deletions(-) create mode 100644 templates/representatives/_representative_contact.haml diff --git a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist/content b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist/content index 20cf6f9c..64e881c0 100644 --- a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist/content +++ b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist/content @@ -10,7 +10,7 @@ - The Political Memory of </title> - <link rel="stylesheet" href="/static/collected/libs/bootstrap/dist/css/bootstrap.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/fontawesome/css/font-awesome.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/flag-icon-css/css/flag-icon.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/CACHE/css/base.6aeeaa87703d.css" type="text/css" /> + <link rel="stylesheet" href="/static/collected/libs/bootstrap/dist/css/bootstrap.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/fontawesome/css/font-awesome.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/flag-icon-css/css/flag-icon.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/CACHE/css/base.66ec921b2740.css" type="text/css" /> <script type="text/javascript" src="/static/collected/libs/jquery/dist/jquery.js"></script> <script type="text/javascript" src="/static/collected/libs/bootstrap/dist/js/bootstrap.js"></script> diff --git a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist_searchjoly/content b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist_searchjoly/content index e7de5972..f164f6e0 100644 --- a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist_searchjoly/content +++ b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby12_displaylist_searchjoly/content @@ -10,7 +10,7 @@ - The Political Memory of </title> - <link rel="stylesheet" href="/static/collected/libs/bootstrap/dist/css/bootstrap.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/fontawesome/css/font-awesome.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/flag-icon-css/css/flag-icon.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/CACHE/css/base.6aeeaa87703d.css" type="text/css" /> + <link rel="stylesheet" href="/static/collected/libs/bootstrap/dist/css/bootstrap.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/fontawesome/css/font-awesome.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/flag-icon-css/css/flag-icon.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/CACHE/css/base.66ec921b2740.css" type="text/css" /> <script type="text/javascript" src="/static/collected/libs/jquery/dist/jquery.js"></script> <script type="text/javascript" src="/static/collected/libs/bootstrap/dist/js/bootstrap.js"></script> diff --git a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby24_displaygrid/content b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby24_displaygrid/content index 9acdba75..c2af6dc3 100644 --- a/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby24_displaygrid/content +++ b/memopol/tests/response_fixtures/RepresentativeListTest.test_page1_paginateby24_displaygrid/content @@ -10,7 +10,7 @@ - The Political Memory of </title> - <link rel="stylesheet" href="/static/collected/libs/bootstrap/dist/css/bootstrap.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/fontawesome/css/font-awesome.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/flag-icon-css/css/flag-icon.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/CACHE/css/base.6aeeaa87703d.css" type="text/css" /> + <link rel="stylesheet" href="/static/collected/libs/bootstrap/dist/css/bootstrap.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/fontawesome/css/font-awesome.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/flag-icon-css/css/flag-icon.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/CACHE/css/base.66ec921b2740.css" type="text/css" /> <script type="text/javascript" src="/static/collected/libs/jquery/dist/jquery.js"></script> <script type="text/javascript" src="/static/collected/libs/bootstrap/dist/js/bootstrap.js"></script> diff --git a/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby12_displaylist/content b/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby12_displaylist/content index 5f7c8f09..4afb6cfc 100644 --- a/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby12_displaylist/content +++ b/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby12_displaylist/content @@ -10,7 +10,7 @@ - The Political Memory of </title> - <link rel="stylesheet" href="/static/collected/libs/bootstrap/dist/css/bootstrap.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/fontawesome/css/font-awesome.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/flag-icon-css/css/flag-icon.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/CACHE/css/base.6aeeaa87703d.css" type="text/css" /> + <link rel="stylesheet" href="/static/collected/libs/bootstrap/dist/css/bootstrap.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/fontawesome/css/font-awesome.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/flag-icon-css/css/flag-icon.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/CACHE/css/base.66ec921b2740.css" type="text/css" /> <script type="text/javascript" src="/static/collected/libs/jquery/dist/jquery.js"></script> <script type="text/javascript" src="/static/collected/libs/bootstrap/dist/js/bootstrap.js"></script> diff --git a/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby24_displaylist/content b/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby24_displaylist/content index 02e261dd..0c50c3a3 100644 --- a/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby24_displaylist/content +++ b/memopol/tests/response_fixtures/RepresentativeListTest.test_page2_paginateby24_displaylist/content @@ -10,7 +10,7 @@ - The Political Memory of </title> - <link rel="stylesheet" href="/static/collected/libs/bootstrap/dist/css/bootstrap.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/fontawesome/css/font-awesome.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/flag-icon-css/css/flag-icon.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/CACHE/css/base.6aeeaa87703d.css" type="text/css" /> + <link rel="stylesheet" href="/static/collected/libs/bootstrap/dist/css/bootstrap.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/fontawesome/css/font-awesome.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/libs/flag-icon-css/css/flag-icon.min.css" type="text/css" /><link rel="stylesheet" href="/static/collected/CACHE/css/base.66ec921b2740.css" type="text/css" /> <script type="text/javascript" src="/static/collected/libs/jquery/dist/jquery.js"></script> <script type="text/javascript" src="/static/collected/libs/bootstrap/dist/js/bootstrap.js"></script> diff --git a/memopol/tests/test_representatives_detail.py b/memopol/tests/test_representatives_detail.py index 5f29b3c6..6e98b679 100644 --- a/memopol/tests/test_representatives_detail.py +++ b/memopol/tests/test_representatives_detail.py @@ -12,9 +12,13 @@ class RepresentativeDetailTest(UrlGetTestMixin, TestCase): # Ensure one-time cached queries occur before the actual test self.client.get(self.url) - with self.assertNumQueries(5): + with self.assertNumQueries(10): """ - One query for the rep details and foreign key (profile) + - One query for reverse relation on phones + - One query for reverse relation on addresses + - One query for reverse relation on emails + - Two queries for reverse relation on websites (social and other) - One query for reverse relation on votes - One query for reverse relation on mandates - One query for reverse relation positions diff --git a/templates/representatives/_representative_block.haml b/templates/representatives/_representative_block.haml index 4537dd56..ca5797bf 100644 --- a/templates/representatives/_representative_block.haml +++ b/templates/representatives/_representative_block.haml @@ -57,27 +57,3 @@ %td - for site in representative.other_websites = site.url|website_link - - .row - .col-md-12 - %h2 Contact information - %table.table.table-condensed.detail-view - - for email in representative.email_set.all - %tr - %th E-mail - %td - = email.email|email_link - - - if representative.phone_set.all|length > 0 - %tr - %th Phone numbers - %td - - for phone in representative.phone_set.all - .phone {{ phone.number }} - - - for address in representative.address_set.all - %tr - %th - = address.name - %td - - include 'representatives/_address_block.html' with address=address \ No newline at end of file diff --git a/templates/representatives/_representative_contact.haml b/templates/representatives/_representative_contact.haml new file mode 100644 index 00000000..4be0c1f6 --- /dev/null +++ b/templates/representatives/_representative_contact.haml @@ -0,0 +1,25 @@ +- load memopol_tags + +.row.representative-contact + .col-md-12 + %h2 Contact information + %table.table.table-condensed.detail-view + - for email in representative.email_set.all + %tr + %th E-mail + %td + = email.email|email_link + + - if representative.phone_set.all|length > 0 + %tr + %th Phone numbers + %td + - for phone in representative.phone_set.all + .phone {{ phone.number }} + + - for address in representative.address_set.all + %tr + %th + = address.name + %td + - include 'representatives/_address_block.html' with address=address diff --git a/templates/representatives/representative_detail.haml b/templates/representatives/representative_detail.haml index 94629ffd..2d81ac86 100644 --- a/templates/representatives/representative_detail.haml +++ b/templates/representatives/representative_detail.haml @@ -12,6 +12,7 @@ .row .col-md-6 - include 'representatives/_representative_block.html' with representative=representative + - include 'representatives/_representative_contact.html' with representative=representative .col-md-6 %h2#votes Votes -- GitLab