-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/diff and other minor issues. #711
Changes from 9 commits
8093d5e
cd09962
06a6da9
f9b095b
82863a6
690ae5a
da35b00
7d45799
0eed19e
13f4a88
5bc4b70
ab1ce42
87c1c26
aef04eb
54118f9
0d9376d
565bff2
aa21af3
1a1224a
8167d23
c320001
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.diff del { | ||
text-decoration: none; | ||
background-color: #ff6565; | ||
} | ||
|
||
.diff ins { | ||
text-decoration: none; | ||
background-color: #73ff73; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,53 @@ | ||
{% load diff_tags %} | ||
{% load i18n %} | ||
{% load static %} | ||
|
||
{% if section_title %} | ||
<h2 class="mt-5 mb-1">{% trans section_title %}</h2> | ||
{% endif %} | ||
{% if sub_title %}<h3 class='mt-3'>{{ sub_title }}</h3>{% endif %} | ||
<table class="proposals-diff "> | ||
<tr> | ||
<th class="proposals-diff-question"></th> | ||
<th class="proposals-diff-answer">{% trans "Vorige aanvraag" %}</th> | ||
<th class="proposals-diff-answer">{% trans "Huidige aanvraag" %}</th> | ||
</tr> | ||
{% if warning %} | ||
{% for row in rows|slice:":1" %} | ||
<tr class="diff-ignore"> | ||
<th>{{ row.verbose_name }}</th> | ||
{# If the first object is missing, place a warning on the first TD #} | ||
{% if missing_object == 'old' %} | ||
<td rowspan='{{ rows|length }}'> | ||
<div class='warning'>{{ warning }}</div> | ||
</td> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th scope="col" width="30%"></th> | ||
<th scope="col" width="35%">{% trans "Vorige aanvraag" %}</th> | ||
<th scope="col" width="35%">{% trans "Huidige aanvraag" %}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% if warning %} | ||
{% for row in rows|slice:":1" %} | ||
<tr class="diff-ignore"> | ||
<th>{{ row.verbose_name }}</th> | ||
{# If the first object is missing, place a warning on the first TD #} | ||
{% if missing_object == 'old' %} | ||
<td rowspan='{{ rows|length }}' class="align-middle"> | ||
<div class='alert alert-info'>{{ warning }}</div> | ||
</td> | ||
<td>{{ row.value }}</td> | ||
{# Otherwise, we're missing the second one, thus we place the warning on the second #} | ||
{% elif missing_object == 'new' %} | ||
<td>{{ row.value }}</td> | ||
<td rowspan='{{ rows|length }}' class="align-middle"> | ||
<div class='alert alert-info'>{{ warning }}</div> | ||
</td> | ||
{% endif %} | ||
</tr> | ||
{% endfor %} | ||
{% for row in rows|slice:"1:" %} | ||
<tr class="diff-ignore"> | ||
<th>{{ row.verbose_name }}</th> | ||
<td>{{ row.value }}</td> | ||
{# Otherwise, we're missing the second one, thus we place the warning on the second #} | ||
{% elif missing_object == 'new' %} | ||
<td>{{ row.value }}</td> | ||
<td rowspan='{{ rows|length }}'> | ||
<div class='warning'>{{ warning }}</div> | ||
</td> | ||
{% endif %} | ||
</tr> | ||
{% endfor %} | ||
{% for row in rows|slice:"1:" %} | ||
<tr class="diff-ignore"> | ||
<th>{{ row.verbose_name }}</th> | ||
<td>{{ row.value }}</td> | ||
</tr> | ||
{% endfor %} | ||
{% else %} | ||
{% for row in rows %} | ||
<tr> | ||
<th>{{ row.verbose_name }}</th> | ||
<td>{{ row.old_value }}</td> | ||
<td>{{ row.new_value }}</td> | ||
</tr> | ||
{% endfor %} | ||
{% endif %} | ||
</tr> | ||
{% endfor %} | ||
{% else %} | ||
{% for row in rows %} | ||
<tr class="diff"> | ||
<th>{{ row.verbose_name }}</th> | ||
<td>{{ row.old_value }}</td> | ||
<td>{{ row.new_value }}</td> | ||
</tr> | ||
{% endfor %} | ||
{% endif %} | ||
</tbody> | ||
</table> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,15 @@ def form_valid(self, form): | |
for study_type in form.fields["study_types"].choices: | ||
form_value = study_type[0] in form.data.getlist("study_types") | ||
form.instance.__setattr__(study_type[0], form_value) | ||
if not form.instance.has_intervention and hasattr( | ||
form.instance, "intervention" | ||
): | ||
form.instance.intervention.delete() | ||
if not form.instance.has_observation and hasattr(form.instance, "observation"): | ||
form.instance.observation.delete() | ||
if not form.instance.has_sessions and form.instance.session_set.all(): | ||
for session in form.instance.session_set.all(): | ||
session.delete() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be annoying to have these instances dangling around when the type is no longer relevant. But the unintentional feature that comes with it is that users can undo deletion by re-enabling it. Which is nice and we would probably want to keep. Best to solve the issues with these objects appearing elsewhere symptomatically. To do this right, we could move to a Or we could assign custom managers to things like Just a suggestion. A couple if statements to fix the diffs is fine by me as well, just a little harder to maintain. |
||
form.instance.save() | ||
|
||
return super(StudyDesign, self).form_valid(form) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ def net_duration(self): | |
if duration := self.task_set.annotate( | ||
total_duration=models.F("duration") * models.F("repeats") | ||
).aggregate(models.Sum("total_duration"))["total_duration__sum"]: | ||
return duration | ||
return duration * self.repeats | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, now that I'm reading the help text again, I am actually thinking, the old version, which did not take session repeats into account is more accurate to the goal of this question. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, net duration should not take these repeats into account. |
||
|
||
return 0 | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks better as a
<td>
rather than a<th>
. The page has so much bold text on it right now.