FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SPPM/project_manager/plugins/views.py at dev · Source-Python-Dev-Team/SPPM · GitHub
Source-Python-Dev-Team
SPPM
Repository navigation
Code
Issues
6
(6)
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
SPPM
/
project_manager
/
plugins
/
views.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
106 lines (84 loc) · 3.41 KB
Breadcrumbs
SPPM
/
project_manager
/
plugins
/
views.py
Copy path
File metadata and controls
106 lines (84 loc) · 3.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
"""Plugin views."""
from
typing
import
Any
# =============================================================================
# IMPORTS
# =============================================================================
# Django
from
django
.
views
.
generic
import
TemplateView
# App
from
project_manager
.
mixins
import
DownloadMixin
from
project_manager
.
plugins
.
constants
import
PLUGIN_RELEASE_URL
from
project_manager
.
plugins
.
models
import
Plugin
,
PluginRelease
# =============================================================================
# ALL DECLARATION
# =============================================================================
__all__
=
(
"PluginCreateView"
,
"PluginEditView"
,
"PluginReleaseDownloadView"
,
"PluginUpdateView"
,
"PluginView"
,
)
# =============================================================================
# VIEWS
# =============================================================================
class
PluginReleaseDownloadView
(
DownloadMixin
):
"""Plugin download view for releases."""
model
=
PluginRelease
project_model
=
Plugin
model_kwarg
=
"plugin"
base_url
=
PLUGIN_RELEASE_URL
class
PluginView
(
TemplateView
):
"""Frontend view for viewing Plugins."""
template_name
=
"retrieve.html"
http_method_names
=
(
"get"
,
"options"
)
def
get_context_data
(
self
,
**
kwargs
:
dict
[
str
,
Any
])
->
dict
[
str
,
Any
]:
"""Add the page title to the context."""
context
=
super
().
get_context_data
(
**
kwargs
)
slug
=
context
.
get
(
"slug"
)
if
slug
is
None
:
context
[
"title"
]
=
"Plugin Listing"
else
:
try
:
plugin
=
Plugin
.
objects
.
get
(
slug
=
slug
)
context
[
"title"
]
=
plugin
.
name
except
Plugin
.
DoesNotExist
:
context
[
"title"
]
=
f'Plugin "
{
slug
}
" not found.'
return
context
class
PluginCreateView
(
TemplateView
):
"""Frontend view for creating Plugins."""
template_name
=
"create.html"
http_method_names
=
(
"get"
,
"options"
)
def
get_context_data
(
self
,
**
kwargs
:
dict
[
str
,
Any
])
->
dict
[
str
,
Any
]:
"""Add the page title to the context."""
context
=
super
().
get_context_data
(
**
kwargs
)
context
[
"title"
]
=
"Create a Plugin"
return
context
class
PluginEditView
(
TemplateView
):
"""Frontend view for editing Plugins."""
template_name
=
"edit.html"
http_method_names
=
(
"get"
,
"options"
)
def
get_context_data
(
self
,
**
kwargs
:
dict
[
str
,
Any
])
->
dict
[
str
,
Any
]:
"""Add the page title to the context."""
context
=
super
().
get_context_data
(
**
kwargs
)
slug
=
context
.
get
(
"slug"
)
try
:
plugin
=
Plugin
.
objects
.
get
(
slug
=
slug
)
context
[
"title"
]
=
f"Edit
{
plugin
.
name
}
"
except
Plugin
.
DoesNotExist
:
context
[
"title"
]
=
f'Plugin "
{
slug
}
" not found.'
return
context
class
PluginUpdateView
(
TemplateView
):
"""Frontend view for updating Plugins."""
template_name
=
"update.html"
http_method_names
=
(
"get"
,
"options"
)
def
get_context_data
(
self
,
**
kwargs
:
dict
[
str
,
Any
])
->
dict
[
str
,
Any
]:
"""Add the page title to the context."""
context
=
super
().
get_context_data
(
**
kwargs
)
slug
=
context
.
get
(
"slug"
)
try
:
plugin
=
Plugin
.
objects
.
get
(
slug
=
slug
)
context
[
"title"
]
=
f"Update
{
plugin
.
name
}
"
except
Plugin
.
DoesNotExist
:
context
[
"title"
]
=
f'Plugin "
{
slug
}
" not found.'
return
context
Back
|
FazBrowse Home
|
New Git URL