| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
No issues with the idea or API design on this one. Just a couple of minor nits and a slight tweak to the model (that will have knock-on effects for the API also).
Sorry, something went wrong.
Thought on this more over the weekend. Out of curiosity, how many maintainer notes would one expect and do we need them to be surfaced to the top above comments? Put another way, would we expect there to be a single uber-important note on a patch, or many notes like a conversation? I'm thinking that a note is really no different from a comment. Rather than adding a whole new model, we could simply extend the Comment model and API to allow creating comments via the web UI and REST API and marking a comment as private (and maybe also hidden, for spammy replies). We would need a visual way to distinguish between "real" comments (i.e. those sent via the mailing list) and other replies we should allow users to filter between the two via a dropdown filter that allows you to show only comments from e.g. a certain author, submitted via the web UI etc. but it could flow a bit better and avoid adding yet another resource to our database and API. Again, this is taken from experience: tools like Bugzilla, GitHub Issues, and Red Hat's Support Portal all work this way, with private comments interleaved with regular comments. What do you think? |
Sorry, something went wrong.
|
I don't imagine patches having many notes at once (although it's possible in the current implementation). I think the idea for it is to provide important context for a patch before the reader dives into the patch so it makes sense to give them more importance than comments, they are similar to a commit message, but can be private and edited without the need to submit a new patch. If they were to be in the middle of a comment thread they wouldn't have the same emphasis on their message. Like you mentioned, notes also have a different way to interact with them, to maintain the privacy they are added through the Web UI / REST API For these reasons notes, in their current state, are different enough from comments to have their own model. I think that if we went with private comments the use case for the feature would be a bit different, but very valid as well |
Sorry, something went wrong.
|
That's right, FWIW, the intention is small number of important notes / one note which can be edited. |
Sorry, something went wrong.
| @@ -0,0 +1,143 @@ | |||
| # Patchwork - automated patch tracking system | |||
| # Copyright (C) 2018 Red Hat | |||
There was a problem hiding this comment.
Probably want a different copyright here.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed
Sorry, something went wrong.
| models.DateTimeField(default=django.utils.timezone.now), | ||
| ), | ||
| ], | ||
| ), |
There was a problem hiding this comment.
This shouldn't be here. I'm going to guess you missed setting abstract in the TimestampMixin.Meta class?
Sorry, something went wrong.
There was a problem hiding this comment.
Added this setting
Sorry, something went wrong.
| updated_at = models.DateTimeField(default=tz_utils.now) | ||
|
|
||
| def update_timestamp(self): | ||
| self.updated_at = tz_utils.now().isoformat() |
There was a problem hiding this comment.
You need to add the following to ensure this doesn't translate to a real table:
class Meta:
abstract = True
Sorry, something went wrong.
|
|
||
| class TimestampMixin(models.Model): | ||
| created_at = models.DateTimeField(default=tz_utils.now) | ||
| updated_at = models.DateTimeField(default=tz_utils.now) |
There was a problem hiding this comment.
I think you want auto_now_add and auto_now for created_at and updated_at, respectively. You should be able to drop update_timestamp and the call to same then.
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.DateField
Sorry, something went wrong.
There was a problem hiding this comment.
Nice catch. Changed to use these options
Sorry, something went wrong.
| ) | ||
| submitter = models.ForeignKey(User, on_delete=models.CASCADE) | ||
| content = models.TextField(null=False, blank=True) | ||
| maintainer_only = models.BooleanField(default=True) |
There was a problem hiding this comment.
Are these not always maintainer-only? Why would we ever want to make them public?
Sorry, something went wrong.
There was a problem hiding this comment.
Not necessarily, it may be used to transmit additional context for reviewers that may not be adequate to have in the commit message, in this context it would make sense to have public notes.
Sorry, something went wrong.
There was a problem hiding this comment.
Any broader discussion should happen on the mailing list, really.
If we're risking splintering the discussion I'd rather not have this feature at all :S
Sorry, something went wrong.
| <h2>Notes</h2> | ||
| {% endif %} | ||
| <a name="{{ item.id }}"></a> | ||
| <div class="submission-message"> |
There was a problem hiding this comment.
Can we use a different class and set the background to a different colour so it stands out? These are presumably rather important.
Sorry, something went wrong.
Sorry, something went wrong.
| @@ -0,0 +1,231 @@ | |||
| # Patchwork - automated patch tracking system | |||
| # Copyright (C) 2018 Red Hat | |||
There was a problem hiding this comment.
Wrong license header?
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed
Sorry, something went wrong.
|
|
||
| if ( | ||
| request.user.is_authenticated | ||
| and patch.project not in request.user.profile.maintainer_projects.all() |
There was a problem hiding this comment.
| and patch.project not in request.user.profile.maintainer_projects.all() | |
| and patch.project in request.user.profile.maintainer_projects.all() |
Assuming I'm reading this correctly, surely the project should be in the user's list of projects they maintain?
Assuming this does need updating, I think we need a test for the UI also.
Sorry, something went wrong.
There was a problem hiding this comment.
Oh I think I was logged in the wrong account when testing it on my end, you are correct, it should be in the user list of projects. I fexed the issue, made the notes show for admin users and added tests for the UI
Sorry, something went wrong.
| may not have. These can also be public so that any user can read them. | ||
| api: | ||
| - | | ||
| The Application version has been updated to v3.2. |
There was a problem hiding this comment.
You don't need this: we'll announce the version bump separately when we cut a release.
Sorry, something went wrong.
There was a problem hiding this comment.
Removed
Sorry, something went wrong.
Sorry, something went wrong.
|
@hero24 I'll investigate / fix the mentioned points over the next week |
Sorry, something went wrong.
| create_note_form = CreateNoteForm() | ||
|
|
||
| if is_maintainer and action == 'edit-note': | ||
| print(edit_cancel) |
There was a problem hiding this comment.
Leftover
Sorry, something went wrong.
| if is_maintainer and action == 'add-note': | ||
| create_note_form = CreateNoteForm() | ||
|
|
||
| if is_maintainer and action == 'edit-note': |
There was a problem hiding this comment.
You have to make sure the other actions are not evaluated after the first match, without the elif when trying to add a note as superuser but not maintainer we get a 403 error.
| if is_maintainer and action == 'edit-note': | |
| elif is_maintainer and action == 'edit-note': |
Sorry, something went wrong.
| form_name = forms.CharField(initial=name, widget=forms.HiddenInput) | ||
| content = forms.CharField(label='Content', widget=forms.Textarea) | ||
| maintainer_only = forms.BooleanField( | ||
| label='Maintainers Only', initial=True, widget=forms.CheckboxInput |
There was a problem hiding this comment.
We must set required=False for checkboxes to enable public notes creation
| label='Maintainers Only', initial=True, widget=forms.CheckboxInput | |
| label='Maintainers Only', initial=True, widget=forms.CheckboxInput, required=False |
Sorry, something went wrong.
| instance.submitter.id, response_data['submitter']['id'] | ||
| ) | ||
|
|
||
| def test_create_note(self): |
There was a problem hiding this comment.
Add create public note for tests
Sorry, something went wrong.
Signed-off-by: andrepapoti <andrepapoti@gmail.com>
Signed-off-by: andrepapoti <andrepapoti@gmail.com>
Added NoteList api. It allows the user to fetch all notes from a specific test or create a new one Added NoteDetail api. It allows the user to fetch, update and delete notes Signed-off-by: andrepapoti <andrepapoti@gmail.com>
Patch serializer returns a fields containing it's notes. Some notes may be filtered out depending on the request's user and on the note maintainer_only attribute Signed-off-by: andrepapoti <andrepapoti@gmail.com>
Bump latest API version to 1.4 Update patchwork.j2 with new note endpoints Add note endpoints to django urls Signed-off-by: andrepapoti <andrepapoti@gmail.com>
Signed-off-by: andrepapoti <andrepapoti@gmail.com>
Signed-off-by: andrepapoti <andrepapoti@gmail.com>
The submission template now includes a section to display notes, these can be filtered out depending if the request user is a maintainer for the patch's project and on the note maintainer_only attribute Signed-off-by: andrepapoti <andrepapoti@gmail.com>
Signed-off-by: andrepapoti <andrepapoti@gmail.com>
|
I've thought about this more, and I'd really like us to re-use the Comment model rather than adding a new Note model. I think this will be much simpler: there's no new models, no new APIs, and no new Admin views. All we need is a private field on the PatchComment and CoverComment models (and ideally a hidden field too, but that can be done separately) and a way to filter by type in the both the REST API and web UI. We'll also need to make some changes to the EmailMixin model (like making msgid nullable) but it's not complicated. Because we avoid the new model, we also avoid any new JOINs, meaning it should also be more performant. I did a quick mock-up of how I'd expect this to look via the web UI: @victor-accarini @andrepapoti Would you be able to rework this to suit? |
Sorry, something went wrong.
There was a problem hiding this comment.
Per last reply.
Sorry, something went wrong.
|
@stephenfin PR #632 is based on your reply. Since there are quite a few differences I pushed into another branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
Add support for maintainers to add notes to patches.
Notes can be either public or private enabling non maintainers users of a certain patches to see them or not.
The API for this feature allows to create, read, update, and delete notes. Reading can be either a detailed view of a note or a list of notes for a specified patch.
The patch serializer was update to include the notes related to it
Related