Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
EdoStorm96 committed Jul 9, 2024
1 parent 88ae92a commit fa8ae66
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 37 deletions.
2 changes: 1 addition & 1 deletion main/templates/base/fetc_form_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{# A block one can use to insert content before the stepper/form container #}
<div class="col-12 text-center">
{% block pre-form-container-content %}{% endblock %}
</div>

</div>
{# todo: responsive design #}
<div class="col-3">
{% block stepper %}
Expand Down
7 changes: 4 additions & 3 deletions main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,10 @@ def get_object(self, queryset=None):
if self.request.user not in supervisor:
raise PermissionDenied
else:
if (self.request.user not in applicants | supervisor and
self.request.user != proposal.created_by
):
if (
self.request.user not in applicants | supervisor
and self.request.user != proposal.created_by
):
raise PermissionDenied

return obj
Expand Down
29 changes: 24 additions & 5 deletions proposals/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
TemplatedModelForm,
)


class ProposalForm(UserKwargModelFormMixin, SoftValidationMixin, ConditionalModelForm):
class Meta:
model = Proposal
Expand Down Expand Up @@ -69,7 +70,10 @@ def clean(self):

self.mark_soft_required(cleaned_data, "date_start")

class ResearcherForm(UserKwargModelFormMixin, SoftValidationMixin, ConditionalModelForm):

class ResearcherForm(
UserKwargModelFormMixin, SoftValidationMixin, ConditionalModelForm
):
class Meta:
model = Proposal
fields = [
Expand Down Expand Up @@ -145,7 +149,11 @@ def clean(self):
)
self.add_error("supervisor", error)

if relation.needs_supervisor and supervisor == self.user and self.instance.status != Proposal.Statuses.SUBMITTED_TO_SUPERVISOR:
if (
relation.needs_supervisor
and supervisor == self.user
and self.instance.status != Proposal.Statuses.SUBMITTED_TO_SUPERVISOR
):
error = forms.ValidationError(
_("Je kunt niet jezelf als promotor/begeleider opgeven.")
)
Expand All @@ -165,7 +173,10 @@ def clean(self):
cleaned_data, "relation", "check_in_course", "student_justification"
)

class OtherResearchersForm(UserKwargModelFormMixin, SoftValidationMixin, ConditionalModelForm):

class OtherResearchersForm(
UserKwargModelFormMixin, SoftValidationMixin, ConditionalModelForm
):
class Meta:
model = Proposal
fields = [
Expand Down Expand Up @@ -241,6 +252,7 @@ def clean(self):

self.check_dependency(cleaned_data, "other_stakeholders", "stakeholders")


class FundingForm(UserKwargModelFormMixin, SoftValidationMixin, ConditionalModelForm):
class Meta:
model = Proposal
Expand Down Expand Up @@ -274,7 +286,10 @@ def clean(self):
cleaned_data, "funding", "needs_name", "funding_name"
)

class ResearchGoalForm(UserKwargModelFormMixin, SoftValidationMixin, ConditionalModelForm):

class ResearchGoalForm(
UserKwargModelFormMixin, SoftValidationMixin, ConditionalModelForm
):
class Meta:
model = Proposal
fields = [
Expand Down Expand Up @@ -327,7 +342,10 @@ def clean(self):
),
)

class PreApprovedForm(UserKwargModelFormMixin, SoftValidationMixin, ConditionalModelForm):

class PreApprovedForm(
UserKwargModelFormMixin, SoftValidationMixin, ConditionalModelForm
):
class Meta:
model = Proposal
fields = [
Expand Down Expand Up @@ -384,6 +402,7 @@ def clean(self):
cleaned_data, "is_pre_approved", "pre_approval_institute"
)


class ProposalStartPracticeForm(TemplatedForm):
practice_reason = forms.ChoiceField(
label=_("Ik maak een oefenaanvraag aan"),
Expand Down
10 changes: 5 additions & 5 deletions proposals/templates/proposals/research_goal_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
{% block html_head %}
{{ block.super }}
<script type="text/javascript"
charset="utf8"
src="{% static 'proposals/js/word_counter.js' %}"></script>
<script>
charset="utf8"
src="{% static 'proposals/js/word_counter.js' %}"></script>
<script>
$(function () {
// adds running wordcounter for the summary and self_assessment text fields
let translated_string = " {% trans 'Aantal woorden:' %} "
wordCounter("summary", translated_string)
wordCounter("self_assessment", translated_string)
});
</script>
</script>
{% endblock %}

{% block pre-form-container-content %}
Expand All @@ -28,4 +28,4 @@

{% block pre-form-text %}
<h3>{% trans "Informatie over het onderzoeksdoel" %}</h3>
{% endblock %}
{% endblock %}
3 changes: 1 addition & 2 deletions proposals/utils/proposal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def available_urls(proposal):
)
)


urls.append(
AvailableURL(
url=reverse("proposals:other_researchers", args=(proposal.pk,)),
Expand All @@ -69,7 +68,7 @@ def available_urls(proposal):
title=_("Informatie over financiering"),
)
)

urls.append(
AvailableURL(
url=reverse("proposals:research_goal", args=(proposal.pk,)),
Expand Down
20 changes: 10 additions & 10 deletions proposals/utils/validate_proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ def _build_forms(proposal: Proposal) -> OrderedDict:

if not proposal.is_pre_assessment:
forms["Funding"] = (
FundingForm,
reverse("proposal:funding", args=[proposal.pk]),
_("Informatie over financiering"),
proposal,
)
FundingForm,
reverse("proposal:funding", args=[proposal.pk]),
_("Informatie over financiering"),
proposal,
)

forms["ResearchGoal"] = (
ResearchGoalForm,
Expand All @@ -79,11 +79,11 @@ def _build_forms(proposal: Proposal) -> OrderedDict:

if proposal.is_pre_approved:
forms["PreApproved"] = (
PreApprovedForm,
reverse("proposal:pre_approved", args=[proposal.pk]),
_("Informatie over eerdere toetsing"),
proposal,
)
PreApprovedForm,
reverse("proposal:pre_approved", args=[proposal.pk]),
_("Informatie over eerdere toetsing"),
proposal,
)

# For pre approved proposals, we're done already!
if proposal.is_pre_approved:
Expand Down
38 changes: 27 additions & 11 deletions proposals/views/proposal_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def form_valid(self, form):
form.instance.reviewing_committee = form.instance.institution.reviewing_chamber
obj = form.save()
obj.applicants.set([self.request.user])
obj.save()
obj.save()
return super(ProposalCreate, self).form_valid(form)

def get_context_data(self, **kwargs):
Expand Down Expand Up @@ -369,8 +369,11 @@ def get_context_data(self, **kwargs):
context = super(ProposalStart, self).get_context_data(**kwargs)
context["secretary"] = get_secretary()
return context

class ProposalResearcherFormView(UserFormKwargsMixin, ProposalContextMixin, AllowErrorsOnBackbuttonMixin, UpdateView):


class ProposalResearcherFormView(
UserFormKwargsMixin, ProposalContextMixin, AllowErrorsOnBackbuttonMixin, UpdateView
):
model = Proposal
form_class = ResearcherForm
template_name = "proposals/researcher_form.html"
Expand All @@ -380,8 +383,11 @@ def get_next_url(self):

def get_back_url(self):
return reverse("proposals:update", args=(self.object.pk,))

class ProposalOtherResearchersFormView(UserFormKwargsMixin, ProposalContextMixin, AllowErrorsOnBackbuttonMixin, UpdateView):


class ProposalOtherResearchersFormView(
UserFormKwargsMixin, ProposalContextMixin, AllowErrorsOnBackbuttonMixin, UpdateView
):
model = Proposal
form_class = OtherResearchersForm
template_name = "proposals/other_researchers_form.html"
Expand All @@ -395,8 +401,11 @@ def get_next_url(self):

def get_back_url(self):
return reverse("proposals:researcher", args=(self.object.pk,))

class ProposalFundingFormView(ProposalContextMixin, AllowErrorsOnBackbuttonMixin, UpdateView):


class ProposalFundingFormView(
ProposalContextMixin, AllowErrorsOnBackbuttonMixin, UpdateView
):
model = Proposal
form_class = FundingForm
template_name = "proposals/funding_form.html"
Expand All @@ -407,7 +416,10 @@ def get_next_url(self):
def get_back_url(self):
return reverse("proposals:other_researchers", args=(self.object.pk,))

class ProposalResearchGoalFormView(ProposalContextMixin, AllowErrorsOnBackbuttonMixin, UpdateView):

class ProposalResearchGoalFormView(
ProposalContextMixin, AllowErrorsOnBackbuttonMixin, UpdateView
):
model = Proposal
form_class = ResearchGoalForm
template_name = "proposals/research_goal_form.html"
Expand All @@ -432,7 +444,10 @@ def get_back_url(self):
else:
return reverse("proposals:funding", args=(self.object.pk,))

class ProposalPreApprovedFormView(ProposalContextMixin, AllowErrorsOnBackbuttonMixin, UpdateView):

class ProposalPreApprovedFormView(
ProposalContextMixin, AllowErrorsOnBackbuttonMixin, UpdateView
):
model = Proposal
form_class = PreApprovedForm
template_name = "proposals/pre_approved_form.html"
Expand All @@ -445,7 +460,8 @@ def get_next_url(self):
def get_back_url(self):
"""Return to the Proposal Form page"""
return reverse("proposals:research_goal", args=(self.object.pk,))



class TranslatedConsentFormsView(UpdateView):
model = Proposal
form_class = TranslatedConsentForms
Expand Down Expand Up @@ -764,6 +780,7 @@ def form_valid(self, form):
form.instance.is_pre_assessment = True
return super(ProposalCreatePreAssessment, self).form_valid(form)


class ProposalSubmitPreAssessment(ProposalSubmit):
def get_next_url(self):
"""After submission, go to the thank-you view"""
Expand Down Expand Up @@ -847,4 +864,3 @@ def form_valid(self, form):
self.kwargs["reason"] == Proposal.PracticeReasons.EXPLORATION
)
return super(ProposalCreatePractice, self).form_valid(form)

0 comments on commit fa8ae66

Please sign in to comment.