Repository: CiviWiki/OpenCiviWiki

Issue:
Migrate threads urls to path
in `threads` app, we need to change `url()`  function with `path()` function as discussed in #1066

https://github.com/CiviWiki/OpenCiviWiki/blob/d7f24fad7c0a2565da3bf2cd54e89a847d7479dd/project/threads/urls.py#L19-L41

Conversion to [path](https://github.com/CiviWiki/OpenCiviWiki/blob/d7f24fad7c0a2565da3bf2cd54e89a847d7479dd/project/threads/urls.py#L19-L41) is simple.

For example,

```python
url(r"^thread_data/(?P<thread_id>\w+)/$", get_thread, name="get thread"),
```

should become

```python
path("thread_data/(<int:thread_id>/", get_thread, name="get thread"),
```

We need to be changed all usages of `url()` function in `threads` app.
Migrate threads urls to path
in `threads` app, we need to change `url()`  function with `path()` function as discussed in #1066

https://github.com/CiviWiki/OpenCiviWiki/blob/d7f24fad7c0a2565da3bf2cd54e89a847d7479dd/project/threads/urls.py#L19-L41

Conversion to [path](https://github.com/CiviWiki/OpenCiviWiki/blob/d7f24fad7c0a2565da3bf2cd54e89a847d7479dd/project/threads/urls.py#L19-L41) is simple.

For example,

```python
url(r"^thread_data/(?P<thread_id>\w+)/$", get_thread, name="get thread"),
```

should become

```python
path("thread_data/(<int:thread_id>/", get_thread, name="get thread"),
```

We need to be changed all usages of `url()` function in `threads` app.


Discussion:
Hi @gorkemarslan @brylie , I wanted to raise a PR for this. Can you add me as collaborator. Getting 403 status code.
I can work on this.
@rishabhjha708, how do you get 403 status code? Could you define in which step you get this error?

@hudson-thomas, @rishabhjha708 comes earlier than you. Could you check other open issues?
@gorkemarslan , I am getting this while push a sub-branch.
I created a sub-branch from develop branch and trying to push that but getting this 
```
rishabhjha@Rishabhs-MacBook-Pro OpenCiviWiki % git push --set-upstream origin migrate_thread_urls
Username for 'https://github.com': rishabhjha708
Password for 'https://rishabhjha708@github.com': 
remote: Permission to CiviWiki/OpenCiviWiki.git denied to rishabhjha708.
fatal: unable to access 'https://github.com/CiviWiki/OpenCiviWiki.git/': The requested URL returned error: 403
```

Tried  again by creating fresh sub branch from develop still got same
```
rishabhjha@Rishabhs-MacBook-Pro OpenCiviWiki % git add .
rishabhjha@Rishabhs-MacBook-Pro OpenCiviWiki % git commit -m "Migration from url to path"
[migrate_thread a5e795a] Migration from url to path
 1 file changed, 16 insertions(+), 16 deletions(-)
rishabhjha@Rishabhs-MacBook-Pro OpenCiviWiki % git push
fatal: The current branch migrate_thread has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin migrate_thread

rishabhjha@Rishabhs-MacBook-Pro OpenCiviWiki % git push --set-upstream origin migrate_thread
Username for 'https://github.com': rishabhjha708
Password for 'https://rishabhjha708@github.com': 
remote: Permission to CiviWiki/OpenCiviWiki.git denied to rishabhjha708.
fatal: unable to access 'https://github.com/CiviWiki/OpenCiviWiki.git/': The requested URL returned error: 403
```
Hi @gorkemarslan @brylie , I wanted to raise a PR for this. Can you add me as collaborator. Getting 403 status code.
I can work on this.
@rishabhjha708, how do you get 403 status code? Could you define in which step you get this error?

@hudson-thomas, @rishabhjha708 comes earlier than you. Could you check other open issues?
@gorkemarslan , I am getting this while push a sub-branch.
I created a sub-branch from develop branch and trying to push that but getting this 
```
rishabhjha@Rishabhs-MacBook-Pro OpenCiviWiki % git push --set-upstream origin migrate_thread_urls
Username for 'https://github.com': rishabhjha708
Password for 'https://rishabhjha708@github.com': 
remote: Permission to CiviWiki/OpenCiviWiki.git denied to rishabhjha708.
fatal: unable to access 'https://github.com/CiviWiki/OpenCiviWiki.git/': The requested URL returned error: 403
```

Tried  again by creating fresh sub branch from develop still got same
```
rishabhjha@Rishabhs-MacBook-Pro OpenCiviWiki % git add .
rishabhjha@Rishabhs-MacBook-Pro OpenCiviWiki % git commit -m "Migration from url to path"
[migrate_thread a5e795a] Migration from url to path
 1 file changed, 16 insertions(+), 16 deletions(-)
rishabhjha@Rishabhs-MacBook-Pro OpenCiviWiki % git push
fatal: The current branch migrate_thread has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin migrate_thread

rishabhjha@Rishabhs-MacBook-Pro OpenCiviWiki % git push --set-upstream origin migrate_thread
Username for 'https://github.com': rishabhjha708
Password for 'https://rishabhjha708@github.com': 
remote: Permission to CiviWiki/OpenCiviWiki.git denied to rishabhjha708.
fatal: unable to access 'https://github.com/CiviWiki/OpenCiviWiki.git/': The requested URL returned error: 403
```

Resolving patch:
diff --git a/project/threads/urls.py b/project/threads/urls.py
--- a/project/threads/urls.py
+++ b/project/threads/urls.py
@@ -1,4 +1,5 @@
-from django.conf.urls import include, url
+from django.conf.urls import include
+from django.urls import path
 from rest_framework.routers import DefaultRouter
 
 from .api import (create_civi, delete_civi, edit_civi, edit_thread, get_civi,
@@ -18,24 +19,24 @@
 router.register(r"accounts", ProfileViewSet)
 
 urlpatterns = [
-    url(r"^v1/", include(router.urls)),
+    path("v1/", include(router.urls)),
 ]
 
 urlpatterns += [
-    url(r"^thread_data/(?P<thread_id>\w+)/$", get_thread, name="get thread"),
-    url(r"^civi_data/(?P<civi_id>\w+)$", get_civi, name="get civi"),
-    url(r"^threads/(?P<thread_id>\w+)/civis$", get_civis, name="get civis"),
-    url(
-        r"^response_data/(?P<thread_id>\w+)/(?P<civi_id>\w+)/$",
+    path("thread_data/<int:thread_id>/", get_thread, name="get thread"),
+    path("civi_data/<int:civi_id>/", get_civi, name="get civi"),
+    path("threads/<int:thread_id>/civis", get_civis, name="get civis"),
+    path(
+        "response_data/<int:thread_id>/<int:civi_id>/",
         get_responses,
         name="get responses",
     ),
-    url(r"^new_thread/$", new_thread, name="new thread"),
-    url(r"^edit_thread/$", edit_thread, name="edit thread"),
-    url(r"^new_civi/$", create_civi, name="new civi"),
-    url(r"^rate_civi/$", rate_civi, name="rate civi"),
-    url(r"^edit_civi/$", edit_civi, name="edit civi"),
-    url(r"^delete_civi/$", delete_civi, name="delete civi"),
-    url(r"^upload_images/$", upload_civi_image, name="upload images"),
-    url(r"^upload_image/$", upload_thread_image, name="upload image"),
+    path("new_thread/", new_thread, name="new thread"),
+    path("edit_thread/", edit_thread, name="edit thread"),
+    path("new_civi/", create_civi, name="new civi"),
+    path("rate_civi/", rate_civi, name="rate civi"),
+    path("edit_civi/", edit_civi, name="edit civi"),
+    path("delete_civi/", delete_civi, name="delete civi"),
+    path("upload_images/", upload_civi_image, name="upload images"),
+    path("upload_image/", upload_thread_image, name="upload image"),
 ]


Test patch: