Skip to content
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

Support prefilled values for new objects #344

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change Log

## 4.12.1

* Support prefilled values via GET parameter for new objects [PR!344](https://github.com/innogames/serveradmin/pull/344)
7 changes: 5 additions & 2 deletions serveradmin/servershell/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def edit(request):
return _edit(request, server, True)


def _edit(request, server, edit_mode=False, template='edit'): # NOQA: C901
def _edit(request: HttpRequest, server, edit_mode=False, template='edit'): # NOQA: C901
# @TODO work with ServerAttribute models here and use Django forms
invalid_attrs = set()
if edit_mode and request.POST:
Expand Down Expand Up @@ -346,6 +346,9 @@ def _edit(request, server, edit_mode=False, template='edit'): # NOQA: C901
):
continue

# Apply pre-filled values from query string if submitted
value = request.GET.get(key, value)

is_related_attribute = False
attribute = attribute_lookup[key]
servertype_attribute = servertype_attributes.get(key)
Expand Down Expand Up @@ -423,7 +426,7 @@ def commit(request):


@login_required
def new_object(request):
def new_object(request: HttpRequest):
servertype = request.GET.get('servertype')

try:
Expand Down
Loading