Skip to content

Commit

Permalink
feat: Add documentation field for trackers (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnu-s authored Mar 26, 2022
1 parent 358d7b7 commit 445312c
Show file tree
Hide file tree
Showing 21 changed files with 179 additions and 58 deletions.
3 changes: 2 additions & 1 deletion doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ The API is served by the URL <https://reports.exodus-privacy.eu.org/>
"creation_date": "2017-12-05",
"website": "https://developers.facebook.com/docs/android",
"description": "",
"categories": ['Analytics', 'Ads']
"categories": ["Analytics", "Ads"],
"documentation": ["https://developers.facebook.com/docs/graph-api/reference/page/locations/"]
},
[edited]
}
Expand Down
8 changes: 7 additions & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ declare -r custom_docker_settings="/exodus/exodus/exodus/settings/custom_docker.

declare -Ar commandList=(
[compile-messages]=compileMessages
[create-db]=createDb
[create-db]=createDB
[create-user]=createUser
[import-trackers]=importTrackers
[init]=init
[make-messages]=makeMessages
[refresh-fdroid-index]=refreshFdroidIndex
[start-frontend]=startFrontEnd
[start-worker]=startWorker
[test]=test
)

declare -Ar commandHelpList=(
Expand All @@ -26,6 +27,7 @@ declare -Ar commandHelpList=(
[refresh-fdroid-index]='fetch F-Droids list of packages'
[start-frontend]='lauch the local front end'
[start-worker]='start the exodus worker'
[test]='run tests'
)

function main()
Expand Down Expand Up @@ -112,6 +114,10 @@ function refreshFdroidIndex() {
$pymanage refresh_fdroid_index
}

function test() {
$pymanage test
}

function init_db() {
while ! pg_isready -h db -U exodus -p 5432 > /dev/null 2> /dev/null; do
echo "Connecting to db (postgresql) Failed: Waiting ..."
Expand Down
1 change: 1 addition & 0 deletions exodus/restful_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Meta:

class TrackerSerializerWithCategories(serializers.ModelSerializer):
category = TrackerCategorySerializer(many=True, read_only=True)
documentation = serializers.ListField(source='documentation_list')

class Meta:
model = Tracker
Expand Down
49 changes: 41 additions & 8 deletions exodus/restful_api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def test_returns_one_tracker(self):
description='bad tracker',
code_signature='com.teemo',
network_signature='teemo.com',
website='https://www.teemo.com'
website='https://www.example.com'
)

expected_json = {
Expand All @@ -336,7 +336,8 @@ def test_returns_one_tracker(self):
'code_signature': tracker.code_signature,
'network_signature': tracker.network_signature,
'website': tracker.website,
'categories': []
'categories': [],
'documentation': []
}
}

Expand All @@ -351,7 +352,7 @@ def test_returns_one_tracker_with_categories(self):
description='bad tracker',
code_signature='com.teemo',
network_signature='teemo.com',
website='https://www.teemo.com'
website='https://www.example.com'
)
category1 = TrackerCategory.objects.create(name='Analytics')
category2 = TrackerCategory.objects.create(name='Ads')
Expand All @@ -367,7 +368,37 @@ def test_returns_one_tracker_with_categories(self):
'code_signature': tracker.code_signature,
'network_signature': tracker.network_signature,
'website': tracker.website,
'categories': ['Analytics', 'Ads']
'categories': ['Analytics', 'Ads'],
'documentation': []
}
}

response = self.client.get(self.PATH)

self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()['trackers'], expected_json)

def test_returns_one_tracker_with_documentation(self):
tracker = Tracker.objects.create(
name='Teemo',
description='bad tracker',
code_signature='com.teemo',
network_signature='teemo.com',
website='https://www.example.com',
documentation='http://example.com/docs http://example.com/android'
)

expected_json = {
str(tracker.id): {
'id': tracker.id,
'name': tracker.name,
'description': tracker.description,
'creation_date': tracker.creation_date.strftime("%Y-%m-%d"),
'code_signature': tracker.code_signature,
'network_signature': tracker.network_signature,
'website': tracker.website,
'categories': [],
'documentation': ['http://example.com/docs', 'http://example.com/android']
}
}

Expand Down Expand Up @@ -510,7 +541,8 @@ def test_returns_detailed_json_when_one_report(self):
description='bad tracker',
code_signature='com.teemo',
network_signature='teemo.com',
website='https://www.teemo.com'
website='https://www.example.com',
documentation='http://example.com/doc'
)
tracker.category.set([category])
report = Report.objects.create(id=1234)
Expand Down Expand Up @@ -551,7 +583,8 @@ def test_returns_detailed_json_when_one_report(self):
'category': [{'name': category.name}],
'website': tracker.website,
'apps_number': 0,
'apps_percent': 0
'apps_percent': 0,
'documentation': ['http://example.com/doc']
},
],
'application': {
Expand Down Expand Up @@ -599,15 +632,15 @@ def test_returns_two_when_two_trackers(self):
description='bad tracker',
code_signature='com.teemo',
network_signature='teemo.com',
website='https://www.teemo.com'
website='https://www.example.com'
)

Tracker.objects.create(
name='Google Ads',
description='bad tracker #2',
code_signature='com.google.ads',
network_signature='google.com',
website='https://www.google.com'
website='https://www.example.com'
)

self._force_authentication()
Expand Down
3 changes: 2 additions & 1 deletion exodus/restful_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def _get_tracker_list():
'code_signature': t.code_signature,
'network_signature': t.network_signature,
'website': t.website,
'categories': [c.name for c in t.category.all()]
'categories': [c.name for c in t.category.all()],
'documentation': [link for link in t.documentation_list()]
}
trackers[t.id] = tracker
return trackers
Expand Down
Binary file modified exodus/trackers/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
21 changes: 13 additions & 8 deletions exodus/trackers/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: exodus-privacy\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-08 11:47+0000\n"
"POT-Creation-Date: 2022-03-26 13:23+0000\n"
"PO-Revision-Date: 2021-03-06 09:27\n"
"Last-Translator: \n"
"Language-Team: German\n"
Expand All @@ -17,6 +17,11 @@ msgstr ""
"X-Crowdin-File: trackers.po\n"
"X-Crowdin-File-ID: 53\n"

#: trackers/templates/new_api_key.html:43
#: trackers/templates/trackers_admin_list.html:24
msgid "You need to be registered"
msgstr "Sie müssen registriert sein"

#: trackers/templates/stats_details.html:9
#: trackers/templates/trackers_list.html:13
msgid "Statistics"
Expand Down Expand Up @@ -58,14 +63,14 @@ msgstr "Code-Erkennungsregel:"
msgid "Network detection rule:"
msgstr "Netzwerkerkennungsregel:"

#: trackers/templates/tracker_details.html:53
#: trackers/templates/tracker_details.html:54
msgid "Documentation"
msgstr "Dokumentation"

#: trackers/templates/tracker_details.html:66
msgid "Latest reports with this tracker"
msgstr "Neueste Berichte mit diesem Tracker"

#: trackers/templates/trackers_admin_list.html:24
msgid "You need to be registered"
msgstr "Sie müssen registriert sein"

#: trackers/templates/trackers_list.html:8
msgid "Trackers"
msgstr "Tracker"
Expand Down Expand Up @@ -96,7 +101,7 @@ msgstr "Nach Namen suchen"
msgid "No trackers are available"
msgstr "Keine Tracker verfügbar"

#: trackers/views.py:22 trackers/views.py:33 trackers/views.py:49
#: trackers/views.py:71
#: trackers/views.py:26 trackers/views.py:37 trackers/views.py:53
#: trackers/views.py:75
msgid "Tracker does not exist"
msgstr "Tracker existiert nicht"
Binary file modified exodus/trackers/locale/el/LC_MESSAGES/django.mo
Binary file not shown.
21 changes: 13 additions & 8 deletions exodus/trackers/locale/el/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: exodus-privacy\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-08 11:47+0000\n"
"POT-Creation-Date: 2022-03-26 13:23+0000\n"
"PO-Revision-Date: 2020-05-04 16:38\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Greek\n"
Expand All @@ -15,6 +15,11 @@ msgstr ""
"X-Crowdin-Language: el\n"
"X-Crowdin-File: trackers.po\n"

#: trackers/templates/new_api_key.html:43
#: trackers/templates/trackers_admin_list.html:24
msgid "You need to be registered"
msgstr "Πρέπει να έχετε εγγραφεί"

#: trackers/templates/stats_details.html:9
#: trackers/templates/trackers_list.html:13
msgid "Statistics"
Expand Down Expand Up @@ -56,14 +61,14 @@ msgstr "Κανόνας ανίχνευσης κώδικα:"
msgid "Network detection rule:"
msgstr "Κανόνας ανίχνευσης δικτύου:"

#: trackers/templates/tracker_details.html:53
#: trackers/templates/tracker_details.html:54
msgid "Documentation"
msgstr "Τεκμηρίωση"

#: trackers/templates/tracker_details.html:66
msgid "Latest reports with this tracker"
msgstr "Τελευταίες αναφορές με αυτό το tracker"

#: trackers/templates/trackers_admin_list.html:24
msgid "You need to be registered"
msgstr "Πρέπει να έχετε εγγραφεί"

#: trackers/templates/trackers_list.html:8
msgid "Trackers"
msgstr "Trackers"
Expand Down Expand Up @@ -94,7 +99,7 @@ msgstr "Αναζήτηση ανά όνομα"
msgid "No trackers are available"
msgstr "Δεν υπάρχουν διαθέσιμα trackers"

#: trackers/views.py:22 trackers/views.py:33 trackers/views.py:49
#: trackers/views.py:71
#: trackers/views.py:26 trackers/views.py:37 trackers/views.py:53
#: trackers/views.py:75
msgid "Tracker does not exist"
msgstr "Το tracker δεν υπάρχει"
19 changes: 12 additions & 7 deletions exodus/trackers/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-08 11:47+0000\n"
"POT-Creation-Date: 2022-03-26 13:23+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -17,6 +17,11 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: trackers/templates/new_api_key.html:43
#: trackers/templates/trackers_admin_list.html:24
msgid "You need to be registered"
msgstr ""

#: trackers/templates/stats_details.html:9
#: trackers/templates/trackers_list.html:13
msgid "Statistics"
Expand Down Expand Up @@ -58,12 +63,12 @@ msgstr ""
msgid "Network detection rule:"
msgstr ""

#: trackers/templates/tracker_details.html:53
msgid "Latest reports with this tracker"
#: trackers/templates/tracker_details.html:54
msgid "Documentation"
msgstr ""

#: trackers/templates/trackers_admin_list.html:24
msgid "You need to be registered"
#: trackers/templates/tracker_details.html:66
msgid "Latest reports with this tracker"
msgstr ""

#: trackers/templates/trackers_list.html:8
Expand Down Expand Up @@ -96,7 +101,7 @@ msgstr ""
msgid "No trackers are available"
msgstr ""

#: trackers/views.py:22 trackers/views.py:33 trackers/views.py:49
#: trackers/views.py:71
#: trackers/views.py:26 trackers/views.py:37 trackers/views.py:53
#: trackers/views.py:75
msgid "Tracker does not exist"
msgstr ""
Binary file modified exodus/trackers/locale/es/LC_MESSAGES/django.mo
Binary file not shown.
21 changes: 13 additions & 8 deletions exodus/trackers/locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: exodus-privacy\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-08 11:47+0000\n"
"POT-Creation-Date: 2022-03-26 13:23+0000\n"
"PO-Revision-Date: 2020-02-07 12:59\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Spanish\n"
Expand All @@ -15,6 +15,11 @@ msgstr ""
"X-Crowdin-Language: es-ES\n"
"X-Crowdin-File: trackers.po\n"

#: trackers/templates/new_api_key.html:43
#: trackers/templates/trackers_admin_list.html:24
msgid "You need to be registered"
msgstr "Necesitas estar registrado"

#: trackers/templates/stats_details.html:9
#: trackers/templates/trackers_list.html:13
msgid "Statistics"
Expand Down Expand Up @@ -56,14 +61,14 @@ msgstr "Regla de detección de código:"
msgid "Network detection rule:"
msgstr "Regla de detección de red:"

#: trackers/templates/tracker_details.html:53
#: trackers/templates/tracker_details.html:54
msgid "Documentation"
msgstr "Documentación"

#: trackers/templates/tracker_details.html:66
msgid "Latest reports with this tracker"
msgstr "Últimos informes con este rastreador"

#: trackers/templates/trackers_admin_list.html:24
msgid "You need to be registered"
msgstr "Necesitas estar registrado"

#: trackers/templates/trackers_list.html:8
msgid "Trackers"
msgstr "Rastreadores"
Expand Down Expand Up @@ -94,7 +99,7 @@ msgstr "Buscar por nombre"
msgid "No trackers are available"
msgstr "No hay rastreadores disponibles"

#: trackers/views.py:22 trackers/views.py:33 trackers/views.py:49
#: trackers/views.py:71
#: trackers/views.py:26 trackers/views.py:37 trackers/views.py:53
#: trackers/views.py:75
msgid "Tracker does not exist"
msgstr "El rastreador no existe"
Binary file modified exodus/trackers/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 445312c

Please sign in to comment.