Skip to content

Views

hypha.apply.api.v1.reminder.views

SubmissionReminderViewSet

Bases: SubmissionNestedMixin, ListModelMixin, CreateModelMixin, GenericViewSet

permission_classes class-attribute instance-attribute

permission_classes = (IsAuthenticated, IsApplyStaffUser)

serializer_class class-attribute instance-attribute

serializer_class = SubmissionReminderSerializer

pagination_class class-attribute instance-attribute

pagination_class = None

get_submission_object

get_submission_object()
Source code in hypha/apply/api/v1/mixin.py
def get_submission_object(self):
    return get_object_or_404(ApplicationSubmission, id=self.kwargs["submission_pk"])

get_queryset

get_queryset()
Source code in hypha/apply/api/v1/reminder/views.py
def get_queryset(self):
    submission = self.get_submission_object()
    return Reminder.objects.filter(submission=submission).order_by("-time")

perform_create

perform_create(serializer)
Source code in hypha/apply/api/v1/reminder/views.py
def perform_create(self, serializer):
    serializer.save(user=self.request.user, submission=self.get_submission_object())

destroy

destroy(request, *args, **kwargs)
Source code in hypha/apply/api/v1/reminder/views.py
def destroy(self, request, *args, **kwargs):
    reminder = self.get_object()
    reminder.delete()
    ser = self.get_serializer(self.get_queryset(), many=True)
    return Response(ser.data)

fields

fields(request, *args, **kwargs)

List details of all the form fields that were created by admin for adding reminders.

These field details will be used in frontend to render the reminder form.

Source code in hypha/apply/api/v1/reminder/views.py
@action(detail=False, methods=["get"])
def fields(self, request, *args, **kwargs):
    """
    List details of all the form fields that were created by admin for adding reminders.

    These field details will be used in frontend to render the reminder form.
    """
    fields = [
        {
            "id": "title",
            "kwargs": {"required": True, "label": "Title", "max_length": 60},
            "type": "TextInput",
        },
        {
            "id": "description",
            "type": "textArea",
            "kwargs": {"label": "Description"},
            "widget": {"attrs": {"cols": 40, "rows": 5}, "type": "Textarea"},
        },
        {
            "id": "time",
            "kwargs": {"label": "Time", "required": True},
            "type": "DateTime",
        },
        {
            "id": "action",
            "kwargs": {
                "label": "Action",
                "required": True,
                "choices": Reminder.ACTIONS.items(),
                "initial": Reminder.REVIEW,
            },
            "type": "Select",
        },
    ]
    return Response(fields)