Repository: nextcloud/appstore

Issue:
Link to categories on forums have to substitute - for _
The links on our forum where you have an underscore get changed to a -, like https://help.nextcloud.com/c/apps/twofactor-u2f from https://apps.nextcloud.com/apps/twofactor_u2f

So we should change that in the links to discussions too :D


Discussion:

Resolving patch:
diff --git a/nextcloudappstore/core/api/v1/views.py b/nextcloudappstore/core/api/v1/views.py
--- a/nextcloudappstore/core/api/v1/views.py
+++ b/nextcloudappstore/core/api/v1/views.py
@@ -106,7 +106,7 @@ def _create_discourse_category(self, app_id: str) -> None:
             settings.DISCOURSE_USER
         )
         data = {
-            'name': app_id,
+            'name': app_id.replace('_', '-'),
             'color': '3c3945',
             'text_color': 'ffffff'
         }
diff --git a/nextcloudappstore/core/templatetags/replace.py b/nextcloudappstore/core/templatetags/replace.py
new file mode 100644
--- /dev/null
+++ b/nextcloudappstore/core/templatetags/replace.py
@@ -0,0 +1,9 @@
+from django import template
+
+register = template.Library()
+
+
+@register.filter(name='replace')
+def replace(value: str, arg: str) -> str:
+    source, target = arg.split(',')
+    return value.replace(source, target)
diff --git a/scripts/development/testdata.py b/scripts/development/testdata.py
--- a/scripts/development/testdata.py
+++ b/scripts/development/testdata.py
@@ -1,5 +1,32 @@
 import requests
 
+twofactor_cert = """
+-----BEGIN CERTIFICATE-----
+MIIECTCCAvECAhASMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD
+VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI
+MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB
+dXRob3JpdHkwHhcNMTYxMDEyMDkzNDMxWhcNMjcwMTE4MDkzNDMxWjAZMRcwFQYD
+VQQDDA50d29mYWN0b3JfdG90cDCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
+ggIBALC1K94104L/nOtmTygx7QNjUcnHs3yrn71mw4pMxTlonXOnMTpwxs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IN CERTIFICATE-----
 MIIEAjCCAuoCAhAzMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD
@@ -99,6 +126,12 @@
         'url': 'https://apps.owncloud.com/CONTENT/content-files/174436'
                '-spreedme.tar.gz'
     }]
+}, {
+    'certificate': twofactor_cert,
+    'releases': [{
+        'url': 'https://github.com/nextcloud/twofactor_totp/releases'
+               '/download/1.2/twofactor_totp.tar.gz'
+    }]
 }]
 
 admin = ('admin', 'admin')


Test patch: