-
Notifications
You must be signed in to change notification settings - Fork 10
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
allow multiple comments per participation #1457
Open
jeriox
wants to merge
11
commits into
main
Choose a base branch
from
participation-comment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4903e14
migrate comments to ParticipationComment
jeriox e62dcfc
adapt views to use new comment model
jeriox 4683f2d
add visibility to forms
jeriox a30d7ba
fix migrations
jeriox 7210278
lint
jeriox bba7af0
fix tests
jeriox 16dfe9d
merge migrations
jeriox 64e8643
fix participation card
jeriox 4e59023
trim translations
jeriox e6b605d
revert poetry.lock
jeriox 9bc0f60
improve dispo layout
jeriox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
from crispy_forms.helper import FormHelper | ||
from crispy_forms.layout import HTML, Field, Layout | ||
from django import forms | ||
from django.db import transaction | ||
from django.utils.formats import date_format | ||
from django.utils.timezone import localtime | ||
from django.utils.translation import gettext_lazy as _ | ||
|
@@ -26,9 +27,6 @@ class BaseParticipationForm(forms.ModelForm): | |
comment_is_public = forms.BooleanField( | ||
label=_("Make comment visible for other participants"), required=False | ||
) | ||
comment_visibility = forms.ChoiceField( | ||
choices=ParticipationComment.Visibility, required=False, widget=forms.HiddenInput | ||
) | ||
|
||
def clean_individual_start_time(self): | ||
if self.cleaned_data["individual_start_time"] == self.shift.start_time: | ||
|
@@ -57,16 +55,17 @@ def clean(self): | |
self.add_error("individual_end_time", _("End time must not be before start time.")) | ||
return cleaned_data | ||
|
||
def save(self, commit=True): | ||
result = super().save(commit) | ||
if comment := self.cleaned_data["comment"]: | ||
ParticipationComment.objects.create( | ||
participation=result, | ||
text=comment, | ||
authored_by_responsible=self.acting_user, | ||
visibile_for=self.cleaned_data["comment_visibility"], | ||
) | ||
return result | ||
def save(self): | ||
with transaction.atomic(): | ||
result = super().save() | ||
if comment := self.cleaned_data["comment"]: | ||
ParticipationComment.objects.create( | ||
participation=result, | ||
text=comment, | ||
authored_by_responsible=self.acting_user, | ||
visibile_for=self.get_comment_visibility(), | ||
) | ||
return result | ||
Comment on lines
+58
to
+68
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. You can use |
||
|
||
class Meta: | ||
model = AbstractParticipation | ||
|
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 |
---|---|---|
|
@@ -63,18 +63,15 @@ <h6 class="d-inline"> | |
{% if form.previous_comments %} | ||
{{ form.previous_comments|as_crispy_field }} | ||
{% endif %} | ||
<div class="row"> | ||
<div class="form-group col"> | ||
{{ form.comment|as_crispy_field }} | ||
<div class="mb-3"> | ||
<div class="form-label"> | ||
{{ form.comment.label_tag }} | ||
<span class="float-end form-check"> | ||
<input type="checkbox" id="{{ form.comment_is_internal.auto_id }}" name="{{ form.comment_is_internal.html_name }}" class="form-check-input"> | ||
{{ form.comment_is_internal.label_tag }} | ||
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. |
||
</span> | ||
</div> | ||
<div class="form-group col-md-2 pt-4"> | ||
<input type="checkbox" class="btn-check" id="{{ form.comment_is_internal.auto_id }}" name="{{ form.comment_is_internal.html_name }}" autocomplete="off"> | ||
<label class="btn btn-outline-primary" for="{{ form.comment_is_internal.auto_id }}"><span class="fa fa-eye-slash"></span></label> | ||
</div> | ||
{# <div class="form-group col">#} | ||
{# <label class="form-label" for="flexSwitchCheckDefault">{{ form.comment_is_internal.label }}</label><br />#} | ||
{# <input class="form-check-input" type="checkbox" id="flexSwitchCheckDefault">#} | ||
{# </div>#} | ||
<input class="form-control" id="{{ form.comment.auto_id }}" name="{{ form.comment.html_name }}"> | ||
</div> | ||
{% block participation_form %} | ||
{% endblock %} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
hmm we can't remove the commit parameter here, as e.g. the named teams Participation Form calls save with the commit parameter. I actually ran into the exception while testing.