Skip to content

Commit

Permalink
Allow staff to change a report's project
Browse files Browse the repository at this point in the history
Implements #368
  • Loading branch information
ColonelThirtyTwo committed Sep 13, 2024
1 parent 52d8b5c commit de38a12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ghostwriter/reporting/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,11 @@ class Meta:

def __init__(self, user=None, project=None, *args, **kwargs):
super().__init__(*args, **kwargs)
# If this is an update, mark the project field as read-only
# Don't allow non-staff users to move a report's project
instance = getattr(self, "instance", None)
if instance and instance.pk:
self.fields["project"].disabled = True
if user is None or not user.is_staff:
self.fields["project"].disabled = True

# Limit the list to the pre-selected project and disable the field
if project:
Expand Down
4 changes: 3 additions & 1 deletion ghostwriter/reporting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,9 @@ def handle_no_permission(self):

def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
kwargs.update({"project": self.get_object().project, "user": self.request.user})
kwargs.update({
"user": self.request.user,
})
return kwargs

def get_context_data(self, **kwargs):
Expand Down

0 comments on commit de38a12

Please sign in to comment.