Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AKPlanning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Blanke
AKPlanning
Commits
e64dacec
Commit
e64dacec
authored
3 years ago
by
Benjamin Hättasch
Committed by
Nadja Geisler
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Move model admin view urls to separate file
parent
d3be2873
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
AKModel/admin.py
+9
-32
9 additions, 32 deletions
AKModel/admin.py
AKModel/urls.py
+41
-7
41 additions, 7 deletions
AKModel/urls.py
with
50 additions
and
39 deletions
AKModel/admin.py
+
9
−
32
View file @
e64dacec
from
django
import
forms
from
django.apps
import
apps
from
django.contrib
import
admin
from
django.contrib.admin
import
SimpleListFilter
from
django.db.models
import
Count
,
F
from
django
import
forms
from
django.shortcuts
import
render
,
redirect
from
django.urls
import
path
,
reverse_lazy
from
django.urls
import
reverse_lazy
from
django.utils
import
timezone
from
django.utils.html
import
format_html
from
django.utils.safestring
import
mark_safe
...
...
@@ -16,9 +16,7 @@ from AKModel.availability.forms import AvailabilitiesFormMixin
from
AKModel.availability.models
import
Availability
from
AKModel.models
import
Event
,
AKOwner
,
AKCategory
,
AKTrack
,
AKTag
,
AKRequirement
,
AK
,
AKSlot
,
Room
,
AKOrgaMessage
,
\
ConstraintViolation
from
AKModel.views
import
EventStatusView
,
AKCSVExportView
,
AKWikiExportView
,
AKMessageDeleteView
,
AKRequirementOverview
,
\
NewEventWizardStartView
,
NewEventWizardSettingsView
,
NewEventWizardPrepareImportView
,
NewEventWizardFinishView
,
\
NewEventWizardImportView
,
NewEventWizardActivateView
from
AKModel.urls
import
get_admin_urls_event_wizard
,
get_admin_urls_event
@admin.register
(
Event
)
...
...
@@ -30,36 +28,15 @@ class EventAdmin(admin.ModelAdmin):
ordering
=
[
'
-start
'
]
def
add_view
(
self
,
request
,
form_url
=
''
,
extra_context
=
None
):
# Always use wizard to create new events
#
(the built-in form wouldn't work anyways since the timezone cannot
be specified before starting to fill the form)
# Always use wizard to create new events
(the built-in form wouldn't work anyways since the timezone cannot
# be specified before starting to fill the form)
return
redirect
(
"
admin:new_event_wizard_start
"
)
def
get_urls
(
self
):
urls
=
super
().
get_urls
()
custom_urls
=
[
path
(
'
add/wizard/start/
'
,
self
.
admin_site
.
admin_view
(
NewEventWizardStartView
.
as_view
()),
name
=
"
new_event_wizard_start
"
),
path
(
'
add/wizard/settings/
'
,
self
.
admin_site
.
admin_view
(
NewEventWizardSettingsView
.
as_view
()),
name
=
"
new_event_wizard_settings
"
),
path
(
'
add/wizard/created/<slug:event_slug>/
'
,
self
.
admin_site
.
admin_view
(
NewEventWizardPrepareImportView
.
as_view
()),
name
=
"
new_event_wizard_prepare_import
"
),
path
(
'
add/wizard/import/<slug:event_slug>/from/<slug:import_slug>/
'
,
self
.
admin_site
.
admin_view
(
NewEventWizardImportView
.
as_view
()),
name
=
"
new_event_wizard_import
"
),
path
(
'
add/wizard/activate/<slug:slug>/
'
,
self
.
admin_site
.
admin_view
(
NewEventWizardActivateView
.
as_view
()),
name
=
"
new_event_wizard_activate
"
),
path
(
'
add/wizard/finish/<slug:slug>/
'
,
self
.
admin_site
.
admin_view
(
NewEventWizardFinishView
.
as_view
()),
name
=
"
new_event_wizard_finish
"
),
path
(
'
<slug:slug>/status/
'
,
self
.
admin_site
.
admin_view
(
EventStatusView
.
as_view
()),
name
=
"
event_status
"
),
path
(
'
<slug:event_slug>/requirements/
'
,
self
.
admin_site
.
admin_view
(
AKRequirementOverview
.
as_view
()),
name
=
"
event_requirement_overview
"
),
path
(
'
<slug:event_slug>/ak-csv-export/
'
,
self
.
admin_site
.
admin_view
(
AKCSVExportView
.
as_view
()),
name
=
"
ak_csv_export
"
),
path
(
'
<slug:event_slug>/ak-wiki-export/
'
,
self
.
admin_site
.
admin_view
(
AKWikiExportView
.
as_view
()),
name
=
"
ak_wiki_export
"
),
path
(
'
<slug:slug>/delete-orga-messages/
'
,
self
.
admin_site
.
admin_view
(
AKMessageDeleteView
.
as_view
()),
name
=
"
ak_delete_orga_messages
"
),
]
return
custom_urls
+
urls
urls
=
get_admin_urls_event_wizard
(
self
.
admin_site
)
urls
.
extend
(
get_admin_urls_event
(
self
.
admin_site
))
urls
.
extend
(
super
().
get_urls
())
return
urls
def
status_url
(
self
,
obj
):
return
format_html
(
"
<a href=
'
{url}
'
>{text}</a>
"
,
...
...
This diff is collapsed.
Click to expand it.
AKModel/urls.py
+
41
−
7
View file @
e64dacec
...
...
@@ -3,6 +3,9 @@ from django.urls import include, path
from
rest_framework.routers
import
DefaultRouter
from
AKModel
import
views
from
AKModel.views
import
NewEventWizardStartView
,
NewEventWizardSettingsView
,
NewEventWizardPrepareImportView
,
\
NewEventWizardImportView
,
NewEventWizardActivateView
,
NewEventWizardFinishView
,
EventStatusView
,
\
AKRequirementOverview
,
AKCSVExportView
,
AKWikiExportView
,
AKMessageDeleteView
api_router
=
DefaultRouter
()
api_router
.
register
(
'
akowner
'
,
views
.
AKOwnerViewSet
,
basename
=
'
AKOwner
'
)
...
...
@@ -12,7 +15,6 @@ api_router.register('ak', views.AKViewSet, basename='AK')
api_router
.
register
(
'
room
'
,
views
.
RoomViewSet
,
basename
=
'
Room
'
)
api_router
.
register
(
'
akslot
'
,
views
.
AKSlotViewSet
,
basename
=
'
AKSlot
'
)
extra_paths
=
[]
if
apps
.
is_installed
(
"
AKScheduling
"
):
from
AKScheduling.api
import
ResourcesViewSet
,
RoomAvailabilitiesView
,
EventsView
,
EventsViewSet
...
...
@@ -22,19 +24,17 @@ if apps.is_installed("AKScheduling"):
extra_paths
=
[
path
(
'
api/scheduling-events/
'
,
EventsView
.
as_view
(),
name
=
'
scheduling-events
'
),
path
(
'
api/scheduling-room-availabilities/
'
,
RoomAvailabilitiesView
.
as_view
(),
name
=
'
scheduling-room-availabilities
'
),
path
(
'
api/scheduling-room-availabilities/
'
,
RoomAvailabilitiesView
.
as_view
(),
name
=
'
scheduling-room-availabilities
'
),
]
event_specific_paths
=
[
path
(
'
api/
'
,
include
(
api_router
.
urls
),
name
=
'
api
'
),
]
path
(
'
api/
'
,
include
(
api_router
.
urls
),
name
=
'
api
'
),
]
event_specific_paths
.
extend
(
extra_paths
)
app_name
=
'
model
'
urlpatterns
=
[
path
(
'
<slug:event_slug>/
'
,
...
...
@@ -42,3 +42,37 @@ urlpatterns = [
),
path
(
'
user/
'
,
views
.
UserView
.
as_view
(),
name
=
"
user
"
),
]
def
get_admin_urls_event_wizard
(
admin_site
):
return
[
path
(
'
add/wizard/start/
'
,
admin_site
.
admin_view
(
NewEventWizardStartView
.
as_view
()),
name
=
"
new_event_wizard_start
"
),
path
(
'
add/wizard/settings/
'
,
admin_site
.
admin_view
(
NewEventWizardSettingsView
.
as_view
()),
name
=
"
new_event_wizard_settings
"
),
path
(
'
add/wizard/created/<slug:event_slug>/
'
,
admin_site
.
admin_view
(
NewEventWizardPrepareImportView
.
as_view
()),
name
=
"
new_event_wizard_prepare_import
"
),
path
(
'
add/wizard/import/<slug:event_slug>/from/<slug:import_slug>/
'
,
admin_site
.
admin_view
(
NewEventWizardImportView
.
as_view
()),
name
=
"
new_event_wizard_import
"
),
path
(
'
add/wizard/activate/<slug:slug>/
'
,
admin_site
.
admin_view
(
NewEventWizardActivateView
.
as_view
()),
name
=
"
new_event_wizard_activate
"
),
path
(
'
add/wizard/finish/<slug:slug>/
'
,
admin_site
.
admin_view
(
NewEventWizardFinishView
.
as_view
()),
name
=
"
new_event_wizard_finish
"
),
]
def
get_admin_urls_event
(
admin_site
):
return
[
path
(
'
<slug:slug>/status/
'
,
admin_site
.
admin_view
(
EventStatusView
.
as_view
()),
name
=
"
event_status
"
),
path
(
'
<slug:event_slug>/requirements/
'
,
admin_site
.
admin_view
(
AKRequirementOverview
.
as_view
()),
name
=
"
event_requirement_overview
"
),
path
(
'
<slug:event_slug>/ak-csv-export/
'
,
admin_site
.
admin_view
(
AKCSVExportView
.
as_view
()),
name
=
"
ak_csv_export
"
),
path
(
'
<slug:event_slug>/ak-wiki-export/
'
,
admin_site
.
admin_view
(
AKWikiExportView
.
as_view
()),
name
=
"
ak_wiki_export
"
),
path
(
'
<slug:slug>/delete-orga-messages/
'
,
admin_site
.
admin_view
(
AKMessageDeleteView
.
as_view
()),
name
=
"
ak_delete_orga_messages
"
),
]
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
register
or
sign in
to comment