Skip to content

Commit

Permalink
Merge branch 'release/0.3.33' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed May 9, 2023
2 parents 51466da + a51436c commit aa50ffe
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
Expand Up @@ -23,6 +23,10 @@ <h6 class="panel-title clearfix">
<a href="{% url 'edc_subject_dashboard:refresh_metadata_actions_url' related_visit.id %}" data-toggle="tooltip" title="Refresh data collection schedule" role="button" class="btn btn-sm btn-default">
<i class="fas fa-arrows-rotate fa-1x fa-fw" aria-hidden="true"></i>
</a>
{% else %}
<a href="{% url 'edc_subject_dashboard:refresh_appointments_url' current_visit_schedule current_schedule subject_identifier %}" data-toggle="tooltip" title="Refresh appointments" role="button" class="btn btn-sm btn-default">
<i class="fas fa-arrows-rotate fa-1x fa-fw" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.edc_data_manager.add_dataquery %}
<a href="{% url 'edc_data_manager_admin:edc_data_manager_dataquery_add' %}?registered_subject={{ registered_subject_pk }}&sender={{ request.user.id }}&visit_schedule={{visit_schedule_pk|default:''}}&visit_code_sequence={{ appointment.visit_code_sequence }}"
Expand Down
Expand Up @@ -38,7 +38,7 @@
<td>{% show_crf_totals wrapped_appointment=wrapped request=request %}</td>
<td>
<!--begin show missed label or nothing -->
{{ wrapped.object.title }}&nbsp{% if wrapped.object.related_visit.reason == MISSED_VISIT %}<span class="label label-default">MISSED</span>{% endif %}
{{ wrapped.object.title }}{% block show_missed_label %}&nbsp{% if wrapped.object.related_visit.reason == MISSED_VISIT %}<span class="label label-default">MISSED</span>{% endif %}{% endblock show_missed_label %}
<!--end show missed label or nothing -->
</td>

Expand Down
7 changes: 6 additions & 1 deletion edc_subject_dashboard/urls.py
Expand Up @@ -4,6 +4,7 @@
from edc_dashboard import url_names

from .views import (
RefreshAppointmentsView,
RefreshMetadataActionsView,
RequisitionPrintActionsView,
RequisitionVerifyActionsView,
Expand All @@ -28,6 +29,11 @@
RefreshMetadataActionsView.as_view(),
name="refresh_metadata_actions_url",
),
path(
"refresh_appointments/<str:visit_schedule>/<str:schedule>/<str:subject_identifier>/",
RefreshAppointmentsView.as_view(),
name="refresh_appointments_url",
),
]

url_names.register(url="requisition_print_actions_url", namespace=app_name)
Expand All @@ -36,7 +42,6 @@


if settings.APP_NAME == app_name:

from edc_appointment.admin_site import edc_appointment_admin

from edc_subject_dashboard.tests.admin import edc_subject_dashboard_admin
Expand Down
1 change: 1 addition & 0 deletions edc_subject_dashboard/views/__init__.py
@@ -1,3 +1,4 @@
from .refresh_appointments_view import RefreshAppointmentsView
from .refresh_metadata_actions_view import RefreshMetadataActionsView
from .requisition_print_actions_view import RequisitionPrintActionsView
from .requisition_verify_actions_view import RequisitionVerifyActionsView
Expand Down
34 changes: 34 additions & 0 deletions edc_subject_dashboard/views/refresh_appointments_view.py
@@ -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)

0 comments on commit aa50ffe

Please sign in to comment.