Skip to content

Commit

Permalink
modify context data before upcall to the parent get_context_data, fil…
Browse files Browse the repository at this point in the history
…ter queryset using new
  • Loading branch information
erikvw committed Dec 18, 2023
1 parent 9a8fc83 commit ff8e761
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
13 changes: 7 additions & 6 deletions edc_adverse_event/view_mixins/ae/ae_listboard_view_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ def print_pdf_report(self, action_identifier=None, request=None):
return None

def get_context_data(self, **kwargs) -> dict:
context = super().get_context_data(**kwargs)
context = self.add_url_to_context(
new_key="ae_home_url", existing_key=self.home_url, context=context
kwargs.update(
{
"AE_INITIAL_ACTION": AE_INITIAL_ACTION,
"utc_date": get_utcnow().date(),
**self.add_url_to_context(new_key="ae_home_url", existing_key=self.home_url),
}
)
context["AE_INITIAL_ACTION"] = AE_INITIAL_ACTION
context["utc_date"] = get_utcnow().date()
return context
return super().get_context_data(**kwargs)

def get_queryset_filter_options(self, request, *args, **kwargs):
options = super().get_queryset_filter_options(request, *args, **kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,17 @@ def print_pdf_report(self, action_identifier=None, request=None):
return None

def get_context_data(self, **kwargs) -> dict:
context = super().get_context_data(**kwargs)
context = self.add_url_to_context(
new_key="ae_home_url", existing_key=self.home_url, context=context
kwargs.update(
{
"DEATH_REPORT_ACTION": DEATH_REPORT_ACTION,
"utc_date": get_utcnow().date(),
**self.add_url_to_context(
new_key="ae_home_url",
existing_key=self.home_url,
),
},
)
context["DEATH_REPORT_ACTION"] = DEATH_REPORT_ACTION
context["utc_date"] = get_utcnow().date()
return context
return kwargs

def get_queryset_filter_options(self, request, *args, **kwargs):
options = super().get_queryset_filter_options(request, *args, **kwargs)
Expand Down
13 changes: 5 additions & 8 deletions edc_adverse_event/views/home_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ class AeHomeView(UrlRequestContextMixin, EdcViewMixin, NavbarViewMixin, Template
url_name = "ae_home_url"

def get_context_data(self, **kwargs):
context = super().get_context_data()
context = self.add_url_to_context(
new_key="ae_home_url", existing_key=self.url_name, context=context
)
context.update(ADVERSE_EVENT_ADMIN_SITE=ADVERSE_EVENT_ADMIN_SITE)
context.update(ADVERSE_EVENT_APP_LABEL=ADVERSE_EVENT_APP_LABEL)
app_list_url = f"{ADVERSE_EVENT_ADMIN_SITE}:app_list"
ae_listboard_url = url_names.get(self.ae_listboard_url)
death_report_listboard_url = url_names.get(self.death_report_listboard_url)
context.update(
kwargs.update(
ADVERSE_EVENT_ADMIN_SITE=ADVERSE_EVENT_ADMIN_SITE,
ADVERSE_EVENT_APP_LABEL=ADVERSE_EVENT_APP_LABEL,
app_list_url=app_list_url,
ae_listboard_url=ae_listboard_url,
death_report_listboard_url=death_report_listboard_url,
**self.add_url_to_context(new_key="ae_home_url", existing_key=self.url_name),
)
return context
return super().get_context_data(**kwargs)

0 comments on commit ff8e761

Please sign in to comment.