Skip to content

Commit

Permalink
#46 #55 #56 Updated url patterns for request update views'.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcaraballo17 committed Oct 30, 2020
1 parent ba7d15a commit c5abdb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/cvinterface/views/base_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def get_queryset(self):
class DefaultVocabularyDetailView(DetailView):
vocabulary = None
vocabulary_verbose = None
pk_url_kwarg = 'vocabulary_id'
exclude = ['name', 'definition', 'vocabulary_id', 'controlledvocabulary_ptr', 'vocabulary_status', 'previous_version']
query_pk_and_slug = True
slug_url_kwarg = 'term'
Expand Down Expand Up @@ -112,6 +113,7 @@ class DefaultRequestUpdateView(SuccessMessageMixin, UpdateView):
vocabulary = None
vocabulary_model = None
request_verbose = None
pk_url_kwarg = 'vocabulary_id'
accept_button = 'request_accept'
reject_button = 'request_reject'
success_message = 'The request has been updated.'
Expand Down Expand Up @@ -145,7 +147,7 @@ def get_context_data(self, **kwargs):
return context

def post(self, request, *args, **kwargs):
object = self.model.objects.get(pk=kwargs['pk'])
object = self.model.objects.get(pk=kwargs['vocabulary_id'])
request.POST._mutable = True
for field in self.read_only:
request.POST[field] = object.__getattribute__(field)
Expand Down Expand Up @@ -219,6 +221,7 @@ class DefaultRequestCreateView(SuccessMessageMixin, CreateView):
request_verbose = None
vocabulary_model = None
vocabulary_verbose = None
pk_url_kwarg = 'vocabulary_id'
recaptcha_key = settings.RECAPTCHA_KEY
success_message = 'Your request has been made successfully.'
exclude = ['request_id', 'status', 'date_submitted', 'date_status_changed', 'request_for', 'request_notes', 'original_request']
Expand Down
11 changes: 5 additions & 6 deletions src/odm2cvs/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Dict
from typing import List

from django.urls import path, include, reverse_lazy
from django.contrib import admin
Expand Down Expand Up @@ -41,10 +41,11 @@

# request list views
for request_name in request_list_views:
vocabulary: str = requests[request_name]["vocabulary"]
view: ListView = request_list_views[request_name]

urlpatterns += [
path(f'requests/{requests[request_name]["vocabulary"]}/', view, name=request_name),
path(f'requests/{vocabulary}/', view, name=request_name),
]

# request create views
Expand All @@ -53,7 +54,7 @@
view: CreateView = request_create_views[request_name]
urlpatterns += [
path(f'requests/{vocabulary}/new/', view, name=f'{vocabulary}_form'),
path(f'requests/{vocabulary}/new/<slug:vocabulary_id>', view, name=f'{vocabulary}_form'),
path(f'requests/{vocabulary}/new/<int:vocabulary_id>', view, name=f'{vocabulary}_form'),
]

# request update views
Expand All @@ -62,7 +63,5 @@
view: UpdateView = request_update_views[request_name]

urlpatterns += [
# TODO: change pk here.
path(f'requests/{requests[request_name]["vocabulary"]}/(?P<pk>[-\w]+)/$', view,
name=requests[request_name]['vocabulary'] + '_update_form'),
path(f'requests/{vocabulary}/<int:vocabulary_id>/', view, name=f'{vocabulary}_update_form'),
]

0 comments on commit c5abdb7

Please sign in to comment.