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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Blanke
AKPlanning
Commits
a54da7ac
Commit
a54da7ac
authored
6 months ago
by
Felix Blanke
Browse files
Options
Downloads
Patches
Plain Diff
Change funcs to export json dict instead of str
parent
abbe82a1
No related branches found
No related tags found
1 merge request
!19
Change json export to assemble a dict instead of sts in the template
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
AKModel/models.py
+5
-5
5 additions, 5 deletions
AKModel/models.py
AKModel/templates/admin/AKModel/ak_json_export.html
+1
-12
1 addition, 12 deletions
AKModel/templates/admin/AKModel/ak_json_export.html
AKModel/views/ak.py
+9
-5
9 additions, 5 deletions
AKModel/views/ak.py
with
15 additions
and
22 deletions
AKModel/models.py
+
5
−
5
View file @
a54da7ac
...
...
@@ -4,7 +4,7 @@ import json
import
math
from
dataclasses
import
dataclass
from
datetime
import
datetime
,
timedelta
from
typing
import
Iterable
,
Generator
from
typing
import
Any
,
Iterable
,
Generator
from
django.db
import
models
,
transaction
from
django.apps
import
apps
...
...
@@ -852,7 +852,7 @@ class Room(models.Model):
def
__str__
(
self
):
return
self
.
title
def
as_json
(
self
)
->
str
:
def
as_json
_dict
(
self
)
->
dict
[
str
,
Any
]
:
"""
Return a json string representation of this room object.
:return: The json string representation is constructed
...
...
@@ -887,7 +887,7 @@ class Room(models.Model):
if
not
any
(
constr
.
startswith
(
"
proxy
"
)
for
constr
in
data
[
"
fulfilled_room_constraints
"
]):
data
[
"
fulfilled_room_constraints
"
].
append
(
"
no-proxy
"
)
return
json
.
dumps
(
data
)
return
data
class
AKSlot
(
models
.
Model
):
...
...
@@ -984,7 +984,7 @@ class AKSlot(models.Model):
self
.
duration
=
min
(
self
.
duration
,
event_duration_hours
)
super
().
save
(
force_insert
,
force_update
,
using
,
update_fields
)
def
as_json
(
self
)
->
str
:
def
as_json
_dict
(
self
)
->
dict
[
str
,
Any
]
:
"""
Return a json string representation of the AK object of this slot.
:return: The json string representation is constructed
...
...
@@ -1055,7 +1055,7 @@ class AKSlot(models.Model):
if
not
any
(
constr
.
startswith
(
"
proxy
"
)
for
constr
in
data
[
"
room_constraints
"
]):
data
[
"
room_constraints
"
].
append
(
"
no-proxy
"
)
return
json
.
dumps
(
data
)
return
data
class
AKOrgaMessage
(
models
.
Model
):
"""
...
...
This diff is collapsed.
Click to expand it.
AKModel/templates/admin/AKModel/ak_json_export.html
+
1
−
12
View file @
a54da7ac
...
...
@@ -4,17 +4,6 @@
{% block content %}
<pre>
{"aks": [
{% for slot in slots %}{{ slot.as_json }}{% if not forloop.last %},
{% endif %}{% endfor %}
],
"rooms": [
{% for room in rooms %}{{ room.as_json }}{% if not forloop.last %},
{% endif %}{% endfor %}
],
"participants": {{ participants }},
"timeslots": {{ timeslots }},
"info": {{ info_dict }}
}
{{ json_data }}
</pre>
{% endblock %}
This diff is collapsed.
Click to expand it.
AKModel/views/ak.py
+
9
−
5
View file @
a54da7ac
...
...
@@ -86,10 +86,10 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
().
get_context_data
(
**
kwargs
)
context
[
"
participants
"
]
=
json
.
dumps
([])
data
=
{}
rooms
=
Room
.
objects
.
filter
(
event
=
self
.
event
)
context
[
"
rooms
"
]
=
rooms
data
[
"
rooms
"
]
=
[
r
.
as_json_dict
()
for
r
in
rooms
]
timeslots
=
{
"
info
"
:
{
"
duration
"
:
float
(
self
.
event
.
export_slot
)},
...
...
@@ -179,17 +179,21 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
timeslots
[
"
info
"
][
"
blocknames
"
]
=
block_names
context
[
"
timeslots
"
]
=
json
.
dumps
(
timeslots
)
info_dict
=
{
"
title
"
:
self
.
event
.
name
,
"
slug
"
:
self
.
event
.
slug
}
for
attr
in
[
"
contact_email
"
,
"
place
"
]:
if
hasattr
(
self
.
event
,
attr
)
and
getattr
(
self
.
event
,
attr
):
info_dict
[
attr
]
=
getattr
(
self
.
event
,
attr
)
context
[
"
info_dict
"
]
=
json
.
dumps
(
info_dict
)
data
[
"
timeslots
"
]
=
timeslots
data
[
"
info
"
]
=
info_dict
data
[
"
participants
"
]
=
[]
data
[
"
aks
"
]
=
[
ak
.
as_json_dict
()
for
ak
in
context
[
"
slots
"
]]
context
[
"
json_data
"
]
=
json
.
dumps
(
data
,
indent
=
2
)
return
context
...
...
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