diff --git a/complaint/tests.py b/complaint/tests.py index 4d85612..83e15c9 100644 --- a/complaint/tests.py +++ b/complaint/tests.py @@ -45,7 +45,7 @@ def test_get_context_data_exist(self): class URLTest(TestCase): - url_names = ['ccdb_landing', 'ccdb_data_use', 'ccdb_process'] + url_names = ['ccdb_submit', 'ccdb_data_use', 'ccdb_process'] def test_complaint_urls(self): for url_name in self.url_names: diff --git a/complaint/urls.py b/complaint/urls.py index abfbbcd..d989452 100644 --- a/complaint/urls.py +++ b/complaint/urls.py @@ -2,7 +2,7 @@ from complaint.views import SubmitView, DataUseView, ProcessView urlpatterns = [ - url(r'^$', SubmitView.as_view(), name='ccdb_landing'), + url(r'^$', SubmitView.as_view(), name='ccdb_submit'), url(r'^data-use/', DataUseView.as_view(), name='ccdb_data_use'), url(r'^process/', ProcessView.as_view(), name='ccdb_process'), ] diff --git a/complaint/views.py b/complaint/views.py index ba34455..5dc3b14 100644 --- a/complaint/views.py +++ b/complaint/views.py @@ -16,6 +16,7 @@ else: # pragma: no cover BASE_TEMPLATE = "front/base_update.html" + class SubmitView(TemplateView): template_name = "submit-a-complaint.html" @@ -24,6 +25,7 @@ def get_context_data(self, **kwargs): context['base_template'] = BASE_TEMPLATE return context + class DataUseView(TemplateView): template_name = "data-use.html" @@ -32,6 +34,7 @@ def get_context_data(self, **kwargs): context['base_template'] = BASE_TEMPLATE return context + class ProcessView(TemplateView): template_name = "process.html" diff --git a/complaintdatabase/tests.py b/complaintdatabase/tests.py index 5bcfab4..f5545c6 100644 --- a/complaintdatabase/tests.py +++ b/complaintdatabase/tests.py @@ -3,6 +3,8 @@ from requests.exceptions import ConnectionError from django.test import RequestFactory, TestCase +from django.core.urlresolvers import reverse +from django.test import Client from datetime import datetime from StringIO import StringIO from .views import (LandingView, DocsView, get_narratives_json, @@ -10,6 +12,7 @@ is_data_not_updated) MOCK_404 = ConnectionError(Mock(return_value={'status': 404}), 'not found') +client = Client() class LandingViewTest(TestCase): @@ -28,6 +31,15 @@ def test_get_context_data_exist(self): self.assertTrue('total_complaints' in response.context_data.keys()) self.assertTrue('timely_responses' in response.context_data.keys()) + def test_demo_json(self): + """Test demo version of landing page""" + response = client.get(reverse("complaintdatabase:ccdb-demo", + kwargs={'demo_json': 'demo.json'})) + self.assertEqual(response.status_code, 200) + self.assertTrue('base_template' in response.context_data.keys()) + self.assertTrue('narratives' in response.context_data.keys()) + self.assertTrue('stats' in response.context_data.keys()) + class NarrativeJsonTest(TestCase): @@ -317,33 +329,6 @@ def test_data_not_updated_friday_narratives_down(self, mock_get_now): self.assertFalse(data_down) self.assertTrue(narratives_down) - # @patch('complaintdatabase.views.get_now') - # def test_data_not_updated_saturday_down(self, mock_get_now): - # mock_get_now.return_value = datetime(2015, 12, 26, 19, 20, 10, 975427) - # input_json = {'stats': {'last_updated': "2015-12-18", - # 'last_updated_narratives': "2015-12-18"}} - # data_down, narratives_down = is_data_not_updated(input_json) - # self.assertTrue(data_down) - # self.assertFalse(narratives_down) - - # @patch('complaintdatabase.views.get_now') - # def test_data_not_updated_saturday_up(self, mock_get_now): - # mock_get_now.return_value = datetime(2015, 12, 26, 19, 20, 10, 975427) - # input_json = {'stats': {'last_updated': "2015-12-21", - # 'last_updated_narratives': "2015-12-21"}} - # data_down, narratives_down = is_data_not_updated(input_json) - # self.assertFalse(data_down) - # self.assertFalse(narratives_down) - - # @patch('complaintdatabase.views.get_now') - # def test_data_not_updated_saturday_narratives_down(self, mock_get_now): - # mock_get_now.return_value = datetime(2015, 12, 26, 19, 20, 10, 975427) - # input_json = {'stats': {'last_updated': "2015-12-21", - # 'last_updated_narratives': "2015-12-18"}} - # data_down, narratives_down = is_data_not_updated(input_json) - # self.assertFalse(data_down) - # self.assertTrue(narratives_down) - @patch('complaintdatabase.views.get_now') def test_data_not_updated_saturday_down(self, mock_get_now): mock_get_now.return_value = datetime(2015, 12, 27, 19, 20, 10, 975427) diff --git a/complaintdatabase/urls.py b/complaintdatabase/urls.py index a083433..8dc1aba 100644 --- a/complaintdatabase/urls.py +++ b/complaintdatabase/urls.py @@ -1,6 +1,19 @@ +from django.conf import settings from django.conf.urls import url from complaintdatabase.views import LandingView +try: + STANDALONE = settings.STANDALONE +except AttributeError: # pragma: no cover + STANDALONE = False + urlpatterns = [ - url(r'^$', LandingView.as_view()), + url(r'^$', LandingView.as_view(), + name='ccdb-landing-page') ] + +if STANDALONE: + urlpatterns += [ + url(r'^demo/(?P[^/]+)/$', LandingView.as_view(), + name='ccdb-demo') + ] diff --git a/complaintdatabase/views.py b/complaintdatabase/views.py index cdce160..2e54b2f 100644 --- a/complaintdatabase/views.py +++ b/complaintdatabase/views.py @@ -17,12 +17,24 @@ class LandingView(TemplateView): + """ + Main page view. + + To run as a standalone demo with local data, put your demo json + in the 'demo.json' file at the project root and use this standalone url: + 'http://127.0.0.1:8000/complaintdatabase/demo/demo.json/' + You can use a different file name; just specify it in the last URL field. + """ + template_name = "landing-page.html" def get_context_data(self, **kwargs): context = super(LandingView, self).get_context_data(**kwargs) context['base_template'] = BASE_TEMPLATE - res_json = get_narratives_json() + if 'demo_json' in kwargs: + res_json = get_narratives_json(demo_json=kwargs['demo_json']) + else: + res_json = get_narratives_json() context['narratives'] = format_narratives(res_json) context['stats'] = get_stats(res_json) (context['total_complaints'], diff --git a/demo.json b/demo.json new file mode 100644 index 0000000..9f7a166 --- /dev/null +++ b/demo.json @@ -0,0 +1 @@ +{"other_financial_services": {"company_public_response": "Company chooses not to provide a public response", "timely": "Yes", "product": "Other financial service", "zip_code": "029XX", "complaint_what_happened": "I mailed a payment to the XXXX XXXX which presented to my checking account on XXXX/XXXX/15. XXXX/XXXX/15 I filed for bankruptcy this account was not included, because of this my insurance paid off the balance of my account causing an over payment. XXXX/XXXX/15 I requested to have the over payment returned, that request was not processed. XXXX/XXXX/15 second request for over payment started this was completed. XXXX/XXXX/15 I received my check and I deposited it on XXXX/XXXX/15 to my account. XXXX/XXXX/15 the check was returned unpaid as unauthorized. My checking account was then charged a {$20.00} fee for a {$25.00} check. I am not out {$45.00} instead of just {$25.00}. XXXX/XXXX/15 I contacted customer service to XXXX for a replacement of funds, they stated someone would contact me back and they would find out why the check returned. XXXX/XXXX/15 I have yet to receive a call back. I have contacted this customer service almost on a daily bases and either the call is dropped or they tell me a supervisor will call back in 24 business hours and yet I have not receive a call or my money. I have requested the telephone number to the corporate office and have been told there is no number. I checked on line found a number that is just a series of voice recording information. \n", "sub_product": "Refund anticipation check", "view_id": "yjne-fppi", "date_sent_to_company": "2015-12-29T02:40:21", "consumer_consent_provided": "Consent provided", "date_received": "2015-12-23T15:08:39", "complaint_id": "1714290", "consumer_disputed": "Yes", "state": "RI", "company_response": "Closed with explanation", "sub_issue": null, "issue": "Unexpected/Other fees", "company": "U.S. Bancorp", "tags": null, "submitted_via": "Web"}, "stats": {"last_updated": "2016-09-02", "percent_timely": 97.0, "response_count": 618981, "complaint_count": 622006, "last_updated_narratives": "2016-09-02"}, "credit_reporting": {"company_public_response": "Company has responded to the consumer and the CFPB and chooses not to provide a public response", "timely": "Yes", "product": "Credit reporting", "zip_code": "871XX", "complaint_what_happened": "There are accounts in my credit report that do not belong to me and Experian is n't responding to my requests to investigate and remove them from my credit report. \n", "sub_product": null, "view_id": "ur78-i5sn", "date_sent_to_company": "2016-03-13T22:39:38", "consumer_consent_provided": "Consent provided", "date_received": "2016-03-12T17:02:14", "complaint_id": "1829525", "consumer_disputed": "No", "state": "NM", "company_response": "Closed with explanation", "sub_issue": "Information is not mine", "issue": "Incorrect information on credit report", "company": "Experian", "tags": null, "submitted_via": "Web"}, "bank_accounts": {"company_public_response": null, "timely": "Yes", "product": "Bank account or service", "zip_code": "902XX", "complaint_what_happened": "I opened a saving account 5 year ago in HSBC XXXX and I have a XXXX credit card with them. I have more than 2 year without use my saving account because I supose that I will use my money when I need it. \nI have two months that I tried to transfer money to XXXX for XXXX friend before I came XXXX and I ca n't do it. I wrote and call several times to the HSBC XXXX and they request to me to send a letter signed with my XXXX copy in order to activate my saving account, I sent it since XX/XX/XXXX2015 by XXXX courier and was received ( I have the received confirmation ) and till now they do n't solve it. I went to the HSBC branch XXXX in California and they told me that they ca n't do nothing because my account XXXX. That is the big problem, because Nobody in HSBC do something to solve it. HSBC have a secure Internet system called \" Contact Center '' which I always use to bring instructions to HSBC regarding security process like unlock my credit card to be used XXXX which I have plan to visit and for increase my daily withdrawal limit in ATM XXXX. All my data is linked to my accounts in HSBC XXXX the XXXX Card Credit and the Saving account ) that why I not understand how I can use my credit card ( I 've already purchased a mobile number here XXXX ) and I be personally in XXXX HSBC branch here XXXX and they have my saving account locked yet. I 've really facing off problem here because I need to have access to my money and make transfers to my credit card for buy food and I can not. Please help me \n", "sub_product": "Savings account", "view_id": "ytxv-uppu", "date_sent_to_company": "2015-10-20T14:25:01", "consumer_consent_provided": "Consent provided", "date_received": "2015-10-16T03:03:22", "complaint_id": "1610301", "consumer_disputed": "No", "state": "CA", "company_response": "Closed with explanation", "sub_issue": null, "issue": "Account opening, closing, or management", "company": "HSBC North America Holdings Inc.", "tags": null, "submitted_via": "Web"}, "up": true, "mortgages": {"company_public_response": "Company has responded to the consumer and the CFPB and chooses not to provide a public response", "timely": "Yes", "product": "Mortgage", "zip_code": "334XX", "complaint_what_happened": "Ok well i have complaint on file against Wells Fargo home mortgage, this update is an addition to what has been updated. We hired XXXX XXXX to represent us and submit for approval of modification. All our income documents are in place and were submitted properly. Apparently now Wells Fargo is lying about our actual monthly income.. They are lying and just denied us for income.. They are criminals they changed our monthly income on their own they have no right to state we make less than we do monthly!! They denied us a modification, It was denied under fraudulent changes that they decided to do., Our income qualifies us!! Our attorney just put appeal with them!!! Wells Fargo deserves to be shut down!! how dare they lie and change our monthly income.. I believe they have complete idiots there that do not comprehend how to figure income since ours is from more then one source. Our attorney even submitted with the breakdown of our monthly incoome!! Someone must stop them from lying and trying to decline us once again!! this must be brought to the media! I reported this situation to congress and other agencies! who will get this horrific company to stop trying to lie to foreclose on us????? \n", "sub_product": "Conventional fixed mortgage", "view_id": "gfmg-6ppu", "date_sent_to_company": "2016-05-24T02:48:46", "consumer_consent_provided": "Consent provided", "date_received": "2016-05-24T02:48:46", "complaint_id": "1936837", "consumer_disputed": "Yes", "state": "FL", "company_response": "Closed with explanation", "sub_issue": null, "issue": "Loan modification,collection,foreclosure", "company": "Wells Fargo & Company", "tags": null, "submitted_via": "Web"}, "student_loans": {"company_public_response": null, "timely": "Yes", "product": "Student loan", "zip_code": "088XX", "complaint_what_happened": "I co-signed a student loan for $ XXXX for my daughter that originated from XXXX and subsequently sold to Discover ( we never received any notice of this takeover ). \nAfter the takeover neither my daughter nor myself received any statements about loan payments due ; then earlier this year Discover started sending notices the loan was 6 months past due and also started the negative reporting to the credit bureaus ( XXXX, XXXX, etc. ). Due to the ineptness of Discover my credit numbers have taken a nosedive by approximately XXXX points. Is the penalty against Discover cover anything about restoring my credit numbers? If so how much time are they allowed to get it corrected? If there is no provision about credit rating restoration why not? Thank you. \n", "sub_product": "Non-federal student loan", "view_id": "j875-kipn", "date_sent_to_company": "2015-07-23T13:19:39", "consumer_consent_provided": "Consent provided", "date_received": "2015-07-23T13:19:38", "complaint_id": "1484146", "consumer_disputed": "Yes", "state": "NJ", "company_response": "Closed with explanation", "sub_issue": "Received bad information about my loan", "issue": "Dealing with my lender or servicer", "company": "Discover", "tags": null, "submitted_via": "Web"}, "credit_cards": {"company_public_response": null, "timely": "Yes", "product": "Credit card", "zip_code": "317XX", "complaint_what_happened": "The monthly payment on my credit card is usually due for payment on XXXX of each month and I make my payments electronically through my bank, regularly on the XXXX or the first working day of each month. When I checked my statement online today, I found that my account has been accessed a late fee of {$38.00}. I further checked my previous statements, only to find that the company started accessing my account late fee as far back as XX/XX/XXXX. I spoke with one of the company 's associates on the phone. She indicated that I have been paying my monthly due amount too early than their billing circle. She agreed to remove only the late fee accessed for XX/XX/XXXX, without removing those accessed from XX/XX/XXXX-XX/XX/XXXX, nor the interests charged on the late fees. It is sad, rather for the company to praise my efforts at making payment ahead of time, I am being charged late fee. I think this is another form of fraudulent credit card charges, when someone is penalized for meeting ones obligation ahead of time. \n", "sub_product": null, "view_id": "wycs-qcs4", "date_sent_to_company": "2015-09-03T03:21:51", "consumer_consent_provided": "Consent provided", "date_received": "2015-09-03T03:21:50", "complaint_id": "1551902", "consumer_disputed": "No", "state": "GA", "company_response": "Closed with monetary relief", "sub_issue": null, "issue": "Late fee", "company": "Synchrony Financial", "tags": null, "submitted_via": "Web"}, "debt_collection": {"company_public_response": null, "timely": "Yes", "product": "Debt collection", "zip_code": "296XX", "complaint_what_happened": "On XXXX/XXXX/XXXX I received a letter fromDynamic Recovery Solutions, XXXX XXXX XXXX XXXX XXXX, XXXX XXXX XXXX stating I owed {$360.00} to XXXX XXXX with no date of services. Account # XXXX. I called the XXXX XXXX number on the number and spoke to XXXX. He demanded money and I had to actually shout at him to get him to stop so I could ask him some questions about this debt. He finally told me that this was from a hospital in XXXX, XXXX.and it was prior to XX/XX/XXXX. I have never been to XXXX, XXXX prior to my cross country trip in XX/XX/XXXX. I was never hospitalized in any hospital in XXXX. When I pressed him for details and a formal billing, he would not provide that, not even a date of service. But he proceeded to demand money. I am not paying for a bill which I have no idea of it 's validity. When asked if they could contact me, I told them not to call. only correspond by mail. Please get them to cease and desist as this is nothing more than a scam. \n", "sub_product": "Other (i.e. phone, health club, etc.)", "view_id": "dx9u-5nhx", "date_sent_to_company": "2016-04-19T12:01:09", "consumer_consent_provided": "Consent provided", "date_received": "2016-04-19T12:01:08", "complaint_id": "1887274", "consumer_disputed": "No", "state": "SC", "company_response": "Closed with non-monetary relief", "sub_issue": "Debt is not mine", "issue": "Cont'd attempts collect debt not owed", "company": "Dynamic Recovery Solutions, LLC", "tags": "Older American, Servicemember", "submitted_via": "Web"}, "virtual_currentcy": {"view_id": "kkwz-p4jr", "complaint_what_happened": ""}, "payday_loans": {"company_public_response": "Company believes it acted appropriately as authorized by contract or law", "timely": "Yes", "product": "Payday loan", "zip_code": "631XX", "complaint_what_happened": "The company is calling harassing me about a loan I know nothing about. They threatened to contact my job \n", "sub_product": "Payday loan", "view_id": "xiq2-ahjv", "date_sent_to_company": "2016-02-29T17:16:58", "consumer_consent_provided": "Consent provided", "date_received": "2016-02-24T17:48:05", "complaint_id": "1802495", "consumer_disputed": "No", "state": "MO", "company_response": "Closed", "sub_issue": "Charged fees or interest I didn't expect", "issue": "Charged fees or interest I didn't expect", "company": "Rosen Management Services Inc.", "tags": null, "submitted_via": "Web"}, "prepaid_cards": {"company_public_response": "Company has responded to the consumer and the CFPB and chooses not to provide a public response", "timely": "Yes", "product": "Prepaid card", "zip_code": "863XX", "complaint_what_happened": "XXXX US Bank {$200.00} gift card bought XXXX/XXXX/16 and opened to use on XXXX/XXXX/16 but both cards had been fraudulently used prior on same day, XXXX/XXXX/16 at XXXX 's in store and Pajama-gram. Card numbers stolen and applied to new fraudulent cards and total amt drained off cards. I am now out {$400.00} \n", "sub_product": "General purpose card", "view_id": "2t2q-2pud", "date_sent_to_company": "2016-04-05T17:52:23", "consumer_consent_provided": "Consent provided", "date_received": "2016-04-02T19:04:10", "complaint_id": "1861565", "consumer_disputed": "No", "state": "AZ", "company_response": "Closed with explanation", "sub_issue": null, "issue": "Fraud or scam", "company": "U.S. Bancorp", "tags": "Servicemember", "submitted_via": "Web"}, "other_consumer_loans": {"company_public_response": null, "timely": "Yes", "product": "Consumer Loan", "zip_code": "190XX", "complaint_what_happened": "I read that Honda Financial Services settled for racial discrimination. How can I find out if I was discriminated against when I signed for a car loan? \n", "sub_product": "Vehicle loan", "view_id": "uqjt-9neg", "date_sent_to_company": "2015-07-16T00:24:56", "consumer_consent_provided": "Consent provided", "date_received": "2015-07-16T00:24:55", "complaint_id": "1471243", "consumer_disputed": "No", "state": "PA", "company_response": "Closed with explanation", "sub_issue": null, "issue": "Taking out the loan or lease", "company": "American Honda Finance Corporation", "tags": null, "submitted_via": "Web"}, "money_transfers": {"company_public_response": null, "timely": "Yes", "product": "Money transfers", "zip_code": "841XX", "complaint_what_happened": "I recently attempted to receive a prescription for saizen hgh from a website that I had not done business with before XXXX I agreed to use moneygram to send {$300.00} to a clinic in XXXX. I was n't completely unaware of the risk of such a transaction, but due to FDA 's recent pressure on credit card companies to stop processing transactions for medicinal products, I found myself feeling like I had no choice but to attempt to do business this way. I wired the {$300.00} on XXXX XXXX, 2016. The salesperson I spoke to on the phone ( XXXX, phone number XXXX ) assured me that he would contact me the next day and provide a tracking number for a package that would be sent overnight delivery. Since the money was sent, all of my attempts at communications have received no response. \n", "sub_product": "International money transfer", "view_id": "d644-vf4p", "date_sent_to_company": "2016-02-03T13:45:22", "consumer_consent_provided": "Consent provided", "date_received": "2016-02-01T21:57:06", "complaint_id": "1767942", "consumer_disputed": "No", "state": "UT", "company_response": "Closed with explanation", "sub_issue": null, "issue": "Fraud or scam", "company": "MoneyGram", "tags": null, "submitted_via": "Web"}}