Skip to content

Commit b9d2385

Browse files
committed
Add necessary files for 'Affected URLs' page
1 parent 933852b commit b9d2385

File tree

5 files changed

+566
-0
lines changed

5 files changed

+566
-0
lines changed

sde_collections/urls.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
view=views.CandidateURLsListView.as_view(),
4444
name="candidate_urls",
4545
),
46+
path(
47+
"exclude-pattern/<int:id>/",
48+
view=views.AffectedURLsListView.as_view(),
49+
name="affected_urls",
50+
),
4651
path(
4752
"consolidate/",
4853
view=views.WebappGitHubConsolidationView.as_view(),

sde_collections/views.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,32 @@ def get_context_data(self, **kwargs):
225225

226226
return context
227227

228+
class AffectedURLsListView(LoginRequiredMixin, ListView):
229+
"""
230+
Display a list of URLs affected by a match pattern
231+
"""
232+
233+
model = CandidateURL
234+
template_name = "sde_collections/affected_urls.html"
235+
context_object_name = "affected_urls"
236+
paginate_by = 100
237+
238+
def get_queryset(self):
239+
self.pattern = ExcludePattern.objects.get(id=self.kwargs["id"])
240+
queryset = self.pattern.matched_urls()
241+
return queryset
242+
243+
def get_context_data(self, **kwargs):
244+
context = super().get_context_data(**kwargs)
245+
context["pattern"] = self.pattern
246+
247+
# affected_urls = self.pattern.matched_urls()
248+
# for url in affected_urls:
249+
# print(url.collection)
250+
# Your affected_urls is a list of CandidateURL model objects.
251+
252+
return context
253+
228254

229255
class SdeDashboardView(LoginRequiredMixin, ListView):
230256
model = Collection

0 commit comments

Comments
 (0)