forked from botswana-harvard/edc-subject-dashboard
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/0.3.33' into main
- Loading branch information
Showing
5 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from django.contrib import messages | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.contrib.messages import SUCCESS | ||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse | ||
from django.views import View | ||
from edc_dashboard import url_names | ||
from edc_visit_schedule import site_visit_schedules | ||
|
||
|
||
class RefreshAppointmentsView(LoginRequiredMixin, View): | ||
onschedule_model = None | ||
|
||
@staticmethod | ||
def refresh_appointments( | ||
subject_identifier: str = None, | ||
visit_schedule: str = None, | ||
schedule: str = None, | ||
**kwargs, | ||
): # noqa | ||
visit_schedule = site_visit_schedules.get_visit_schedule(visit_schedule) | ||
schedule = visit_schedule.schedules.get(schedule) | ||
schedule.refresh_schedule(subject_identifier=subject_identifier) | ||
return subject_identifier | ||
|
||
def get(self, request, *args, **kwargs): | ||
subject_identifier = self.refresh_appointments(**kwargs) | ||
url_name = url_names.get("subject_dashboard_url") | ||
args = (subject_identifier,) | ||
url = reverse(url_name, args=args) | ||
messages.add_message( | ||
request, SUCCESS, f"The appointments for {subject_identifier} have been refreshed " | ||
) | ||
return HttpResponseRedirect(url) |