Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Public contract registry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Public contract registry
Commits
c838bc46
Commit
c838bc46
authored
3 months ago
by
Alexa Valentová
Browse files
Options
Downloads
Patches
Plain Diff
Handle auto-imported contracts better
parent
92440753
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#20999
passed
3 months ago
Stage: build
Stage: test_deploy
Changes
3
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
contracts/admin.py
+10
-4
10 additions, 4 deletions
contracts/admin.py
contracts/forms.py
+1
-0
1 addition, 0 deletions
contracts/forms.py
with
12 additions
and
5 deletions
Makefile
+
1
−
1
View file @
c838bc46
#!/usr/bin/make -f
#!/usr/bin/make -f
PYTHON
=
python3.1
1
PYTHON
=
python3.1
2
VENV
=
.venv
VENV
=
.venv
PORT
=
8013
PORT
=
8013
SETTINGS
=
registry.settings.dev
SETTINGS
=
registry.settings.dev
...
...
This diff is collapsed.
Click to expand it.
contracts/admin.py
+
10
−
4
View file @
c838bc46
...
@@ -88,7 +88,9 @@ class OwnPermissionsMixin(
...
@@ -88,7 +88,9 @@ class OwnPermissionsMixin(
)
)
):
):
def
save_model
(
self
,
request
,
obj
,
form
,
change
):
def
save_model
(
self
,
request
,
obj
,
form
,
change
):
if
obj
.
created_by
is
None
:
# If there is a primary key already assigned, this is an auto-generated
# contract that shouldn't have an author at all.
if
obj
.
created_by
is
None
and
obj
.
pk
is
None
:
obj
.
created_by
=
request
.
user
obj
.
created_by
=
request
.
user
return
super
().
save_model
(
request
,
obj
,
form
,
change
)
return
super
().
save_model
(
request
,
obj
,
form
,
change
)
...
@@ -250,7 +252,7 @@ class ContractAdmin(
...
@@ -250,7 +252,7 @@ class ContractAdmin(
search_fields
=
(
"
name
"
,)
search_fields
=
(
"
name
"
,)
readonly_fields
=
(
readonly_fields
=
(
"
created_by
"
,
#
"created_by",
-- Dynamic
"
created_on
"
,
"
created_on
"
,
"
updated_on
"
,
"
updated_on
"
,
)
)
...
@@ -606,8 +608,6 @@ class ContractAdmin(
...
@@ -606,8 +608,6 @@ class ContractAdmin(
return
parent_save_response
return
parent_save_response
def
get_readonly_fields
(
self
,
request
,
obj
=
None
):
def
get_readonly_fields
(
self
,
request
,
obj
=
None
):
readonly_fields
=
[]
fields
=
[]
fields
=
[]
for
fieldset
in
self
.
get_fieldsets
(
request
):
for
fieldset
in
self
.
get_fieldsets
(
request
):
...
@@ -621,8 +621,14 @@ class ContractAdmin(
...
@@ -621,8 +621,14 @@ class ContractAdmin(
):
):
fields
.
remove
(
"
status
"
)
fields
.
remove
(
"
status
"
)
if
request
.
user
.
is_superuser
:
fields
.
remove
(
"
created_by
"
)
return
fields
return
fields
if
not
request
.
user
.
is_superuser
:
return
list
(
self
.
readonly_fields
)
+
[
"
created_by
"
]
return
list
(
self
.
readonly_fields
)
return
list
(
self
.
readonly_fields
)
def
has_change_permission
(
self
,
request
,
obj
=
None
):
def
has_change_permission
(
self
,
request
,
obj
=
None
):
...
...
This diff is collapsed.
Click to expand it.
contracts/forms.py
+
1
−
0
View file @
c838bc46
...
@@ -94,6 +94,7 @@ class ContractAdminForm(forms.ModelForm):
...
@@ -94,6 +94,7 @@ class ContractAdminForm(forms.ModelForm):
and
choice_key
==
Contract
.
StatusTypes
.
TO_BE_APPROVED
and
choice_key
==
Contract
.
StatusTypes
.
TO_BE_APPROVED
and
self
.
current_user
.
has_perm
(
"
contracts.approve
"
)
and
self
.
current_user
.
has_perm
(
"
contracts.approve
"
)
):
):
print
(
"
allowing
"
)
allowed_choices
.
append
(
allowed_choices
.
append
(
(
(
choice_key
,
choice_key
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment