Skip to content

Commit

Permalink
Use FQDN when sending issues to asana
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoWill committed Jun 18, 2024
1 parent 7dbd30a commit 5ff094f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions polling_stations/apps/bug_reports/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from urllib.parse import urljoin

from django.conf import settings
Expand Down Expand Up @@ -33,15 +34,15 @@ class BugReport(TimeStampedModel):

def as_asana_object(self):
desc = truncatechars(self.description, 30)
fqdn = os.environ.get("FQDN", "wheredoivote.co.uk")
base_url = f"https://{fqdn}"
return {
"name": f"""{self.pk}: "{desc}" """,
"projects": [settings.ASANA_PROJECT_ID],
"custom_fields": {
settings.ASANA_SITE_LINK_FIELD_ID: urljoin(
"https://wheredoivote.co.uk", self.source_url
),
settings.ASANA_SITE_LINK_FIELD_ID: urljoin(base_url, self.source_url),
settings.ASANA_REPORT_LINK_FIELD_ID: urljoin(
"https://wheredoivote.co.uk",
base_url,
reverse(
"admin:bug_reports_bugreport_change",
kwargs={"object_id": self.pk},
Expand Down
9 changes: 5 additions & 4 deletions polling_stations/apps/feedback/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from urllib.parse import urljoin

from django.conf import settings
Expand Down Expand Up @@ -25,15 +26,15 @@ class Feedback(TimeStampedModel):

def as_asana_object(self):
desc = truncatechars(self.comments, 30)
fqdn = os.environ.get("FQDN", "wheredoivote.co.uk")
base_url = f"https://{fqdn}"
return {
"name": f"""{self.pk}: "{desc}" """,
"projects": [settings.ASANA_PROJECT_ID],
"custom_fields": {
settings.ASANA_SITE_LINK_FIELD_ID: urljoin(
"https://wheredoivote.co.uk", self.source_url
),
settings.ASANA_SITE_LINK_FIELD_ID: urljoin(base_url, self.source_url),
settings.ASANA_REPORT_LINK_FIELD_ID: urljoin(
"https://wheredoivote.co.uk",
base_url,
reverse(
"admin:feedback_feedback_change",
kwargs={"object_id": self.pk},
Expand Down

0 comments on commit 5ff094f

Please sign in to comment.