Repository: shahryorg/django-ads-txt (language: python)

Issue:
Template appends <br> to end of line
The ads.txt file is a textfile, not an html file, so the end of line should not be terminated with <br>, but instead with a newline character. I am not sure if this will affect the parsing, but Google didn't validate my ads.txt yet, so I used an online validator where I noticed this problem. I will create a PR which resolves this issue and link to it in the comments.


Discussion / hints:
Fix is provided here: https://github.com/flyingelephantlab/django-ads-txt/pull/6
I'm not yet sure if this works as intended, currently trying to identify why the wrong code still gets deployed with my application, but my ads.txt has already been validated regardless of the trailing <br>, yet I think this issue should be addressed.

Fix patch:
diff --git a/ads_txt/templates/ads_txt/rule_list.html b/ads_txt/templates/ads_txt/rule_list.html
index d21491b..5dab22f 100644
--- a/ads_txt/templates/ads_txt/rule_list.html
+++ b/ads_txt/templates/ads_txt/rule_list.html
@@ -1,7 +1,2 @@
-{% load l10n %}
-{% if rules %}
-{% for rule in rules %}
-{{ rule.domain }}, {{ rule.account_id }}, {{ rule.account_type }}{% if rule.authority_id %}, {{ rule.authority_id }}{% endif %}<br>
-{% endfor %}
-{% endif %}
-
+{% if rules %}{% for rule in rules %}{{ rule.domain }}, {{ rule.account_id }}, {{ rule.account_type }}{% if rule.authority_id %}, {{ rule.authority_id }}{% endif %}
+{% endfor %}{% endif %}
diff --git a/ads_txt/views.py b/ads_txt/views.py
index 6374c54..2bd6c68 100644
--- a/ads_txt/views.py
+++ b/ads_txt/views.py
@@ -9,6 +9,7 @@ class RuleList(ListView):
     model = Rule
     context_object_name = 'rules'
     cache_timeout = settings.CACHE_TIMEOUT
+    content_type = 'text/plain'
 
     def get_cache_timeout(self):
         return self.cache_timeout


Test patch:
diff --git a/tests/test_views.py b/tests/test_views.py
index 00d3a86..30fab0f 100644
--- a/tests/test_views.py
+++ b/tests/test_views.py
@@ -4,16 +4,17 @@
 
 
 class AdsTxtTest(TestCase):
-
     def setUp(self):
         self.client = Client()
-        Rule.objects.create(domain='test.com',
-                            account_id='121243d',
-                            account_type='DIRECT',
-                            authority_id=''
-                            )
+        Rule.objects.create(
+            domain='test.com',
+            account_id='121243d',
+            account_type='DIRECT',
+            authority_id='',
+        )
 
     def test_get_ads_txt(self):
         response = self.client.get('/')
         self.assertEqual(response.status_code, 200)
+        self.assertEqual(response.get('content-type'), 'text/plain')
         self.assertIn('test.com', str(response.content))