Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Taiko Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Taiko Web
Commits
61e521dd
Commit
61e521dd
authored
Mar 15, 2020
by
Bui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update song edit page
parent
38f1384f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
21 deletions
+104
-21
app.py
app.py
+45
-2
public/src/css/admin.css
public/src/css/admin.css
+8
-1
templates/admin_song_detail.html
templates/admin_song_detail.html
+47
-14
tools/migrate_db.py
tools/migrate_db.py
+4
-4
No files found.
app.py
View file @
61e521dd
...
...
@@ -7,7 +7,7 @@ import schema
import
os
from
functools
import
wraps
from
flask
import
Flask
,
g
,
jsonify
,
render_template
,
request
,
abort
,
redirect
,
session
from
flask
import
Flask
,
g
,
jsonify
,
render_template
,
request
,
abort
,
redirect
,
session
,
flash
from
flask_caching
import
Cache
from
flask_session
import
Session
from
ffmpy
import
FFmpeg
...
...
@@ -135,9 +135,52 @@ def route_admin_songs_id(id):
categories
=
list
(
db
.
categories
.
find
({}))
song_skins
=
list
(
db
.
song_skins
.
find
({}))
makers
=
list
(
db
.
makers
.
find
({}))
user
=
db
.
users
.
find_one
({
'username'
:
session
[
'username'
]})
return
render_template
(
'admin_song_detail.html'
,
song
=
song
,
categories
=
categories
,
song_skins
=
song_skins
)
song
=
song
,
categories
=
categories
,
song_skins
=
song_skins
,
makers
=
makers
,
admin
=
user
)
@
app
.
route
(
'/admin/songs/<int:id>'
,
methods
=
[
'POST'
])
@
admin_required
def
route_admin_songs_id_post
(
id
):
song
=
db
.
songs
.
find_one
({
'id'
:
id
})
if
not
song
:
return
abort
(
404
)
user
=
db
.
users
.
find_one
({
'username'
:
session
[
'username'
]})
user_level
=
user
[
'user_level'
]
output
=
{
'title_lang'
:
{},
'subtitle_lang'
:
{},
'courses'
:
{}}
if
user_level
>=
100
:
output
[
'enabled'
]
=
True
if
request
.
form
.
get
(
'enabled'
)
else
False
output
[
'title'
]
=
request
.
form
.
get
(
'title'
)
or
None
output
[
'subtitle'
]
=
request
.
form
.
get
(
'subtitle'
)
or
None
for
lang
in
[
'ja'
,
'en'
,
'cn'
,
'tw'
,
'ko'
]:
output
[
'title_lang'
][
lang
]
=
request
.
form
.
get
(
'title_
%
s'
%
lang
)
or
None
output
[
'subtitle_lang'
][
lang
]
=
request
.
form
.
get
(
'subtitle_
%
s'
%
lang
)
or
None
for
course
in
[
'easy'
,
'normal'
,
'hard'
,
'oni'
,
'ura'
]:
if
request
.
form
.
get
(
'course_
%
s'
%
course
):
output
[
'courses'
][
course
]
=
{
'stars'
:
int
(
request
.
form
.
get
(
'course_
%
s'
%
course
)),
'branch'
:
True
if
request
.
form
.
get
(
'branch_
%
s'
%
course
)
else
False
}
else
:
output
[
'courses'
][
course
]
=
None
output
[
'category_id'
]
=
int
(
request
.
form
.
get
(
'category_id'
))
output
[
'type'
]
=
request
.
form
.
get
(
'type'
)
output
[
'offset'
]
=
float
(
request
.
form
.
get
(
'offset'
))
or
None
output
[
'skin_id'
]
=
int
(
request
.
form
.
get
(
'skin_id'
))
or
None
output
[
'preview'
]
=
float
(
request
.
form
.
get
(
'preview'
))
or
None
output
[
'volume'
]
=
float
(
request
.
form
.
get
(
'volume'
))
or
None
output
[
'maker_id'
]
=
int
(
request
.
form
.
get
(
'maker_id'
))
or
None
db
.
songs
.
update_one
({
'id'
:
id
},
{
'$set'
:
output
})
flash
(
'Changes saved.'
)
return
redirect
(
'/admin/songs/
%
s'
%
id
)
@
app
.
route
(
'/api/preview'
)
...
...
public/src/css/admin.css
View file @
61e521dd
...
...
@@ -122,4 +122,11 @@ h1 small {
.checkbox
input
{
margin-right
:
3px
;
margin-left
:
5px
;
}
\ No newline at end of file
}
.message
{
background
:
#2c862f
;
padding
:
15px
;
margin-bottom
:
10px
;
color
:
white
;
}
templates/admin_song_detail.html
View file @
61e521dd
{% extends 'admin.html' %}
{% block content %}
<h1>
{{ song.title }}
<small>
(ID: {{ song.id }})
</small></h1>
{% for message in get_flashed_messages() %}
<div
class=
"message"
>
{{ message }}
</div>
{% endfor %}
<div
class=
"song-form"
>
<form
method=
"post"
>
<div
class=
"form-field"
>
<span
class=
"checkbox"
><input
type=
"checkbox"
name=
"enabled"
id=
"enabled"
{%
if
song
.
enabled
%}
checked
{%
endif
%}
><label
for=
"enabled"
>
Enabled
</label></span>
<span
class=
"checkbox"
><input
type=
"checkbox"
name=
"enabled"
id=
"enabled"
{%
if
song
.
enabled
%}
checked
{%
endif
%}
{%
if
admin
.
user_level
<
100
%}
disabled
{%
endif
%}
><label
for=
"enabled"
>
Enabled
</label></span>
</div>
<div
class=
"form-field"
>
<p>
Title
</p>
<label
for=
"title"
>
Original
</label>
<input
type=
"text"
id=
"title"
value=
"{{song.title
}}"
name=
"title"
>
<input
type=
"text"
id=
"title"
value=
"{{song.title
or ''}}"
name=
"title"
required
>
<label
for=
"title_ja"
>
Japanese
</label>
<input
type=
"text"
id=
"title_ja"
value=
"{{song.title_lang.ja}}"
name=
"title_ja"
>
<input
type=
"text"
id=
"title_ja"
value=
"{{song.title_lang.ja
or ''
}}"
name=
"title_ja"
>
<label
for=
"title_en"
>
English
</label>
<input
type=
"text"
id=
"title_en"
value=
"{{song.title_lang.en}}"
name=
"title_en"
>
<input
type=
"text"
id=
"title_en"
value=
"{{song.title_lang.en
or ''
}}"
name=
"title_en"
>
<label
for=
"title_cn"
>
Chinese (Simplified)
</label>
<input
type=
"text"
id=
"title_cn"
value=
"{{song.title_lang.cn}}"
name=
"title_cn"
>
<input
type=
"text"
id=
"title_cn"
value=
"{{song.title_lang.cn
or ''
}}"
name=
"title_cn"
>
<label
for=
"title_tw"
>
Chinese (Traditional)
</label>
<input
type=
"text"
id=
"title_tw"
value=
"{{song.title_lang.tw}}"
name=
"title_tw"
>
<input
type=
"text"
id=
"title_tw"
value=
"{{song.title_lang.tw
or ''
}}"
name=
"title_tw"
>
<label
for=
"title_ko"
>
Korean
</label>
<input
type=
"text"
id=
"title_ko"
value=
"{{song.title_lang.ko}}"
name=
"title_ko"
>
<input
type=
"text"
id=
"title_ko"
value=
"{{song.title_lang.ko
or ''
}}"
name=
"title_ko"
>
</div>
<div
class=
"form-field"
>
<p>
Subtitle
</p>
<label
for=
"subtitle"
>
Original
</label>
<input
type=
"text"
id=
"subtitle"
value=
"{{song.subtitle}}"
name=
"subtitle"
>
<input
type=
"text"
id=
"subtitle"
value=
"{{song.subtitle
or ''
}}"
name=
"subtitle"
>
<label
for=
"subtitle_ja"
>
Japanese
</label>
<input
type=
"text"
id=
"subtitle_ja"
value=
"{{song.subtitle_lang.ja}}"
name=
"subtitle_ja"
>
<input
type=
"text"
id=
"subtitle_ja"
value=
"{{song.subtitle_lang.ja
or ''
}}"
name=
"subtitle_ja"
>
<label
for=
"subtitle_en"
>
English
</label>
<input
type=
"text"
id=
"subtitle_en"
value=
"{{song.subtitle_lang.en}}"
name=
"subtitle_en"
>
<input
type=
"text"
id=
"subtitle_en"
value=
"{{song.subtitle_lang.en
or ''
}}"
name=
"subtitle_en"
>
<label
for=
"subtitle_cn"
>
Chinese (Simplified)
</label>
<input
type=
"text"
id=
"subtitle_cn"
value=
"{{song.subtitle_lang.cn}}"
name=
"subtitle_cn"
>
<input
type=
"text"
id=
"subtitle_cn"
value=
"{{song.subtitle_lang.cn
or ''
}}"
name=
"subtitle_cn"
>
<label
for=
"subtitle_tw"
>
Chinese (Traditional)
</label>
<input
type=
"text"
id=
"subtitle_tw"
value=
"{{song.subtitle_lang.tw}}"
name=
"subtitle_tw"
>
<input
type=
"text"
id=
"subtitle_tw"
value=
"{{song.subtitle_lang.tw
or ''
}}"
name=
"subtitle_tw"
>
<label
for=
"subtitle_ko"
>
Korean
</label>
<input
type=
"text"
id=
"subtitle_ko"
value=
"{{song.subtitle_lang.ko}}"
name=
"subtitle_ko"
>
<input
type=
"text"
id=
"subtitle_ko"
value=
"{{song.subtitle_lang.ko
or ''
}}"
name=
"subtitle_ko"
>
</div>
<div
class=
"form-field"
>
...
...
@@ -78,7 +81,37 @@
<div
class=
"form-field"
>
<p><label
for=
"offset"
>
Offset
</label></p>
<input
type=
"text"
id=
"offset"
value=
"{{song.offset}}"
name=
"offset"
>
<input
type=
"text"
id=
"offset"
value=
"{{song.offset or '0'}}"
name=
"offset"
required
>
</div>
<div
class=
"form-field"
>
<p><label
for=
"skin_id"
>
Skin
</label></p>
<select
name=
"skin_id"
id=
"skin_id"
>
<option
value=
"0"
>
(none)
</option>
{% for skin in song_skins %}
<option
value=
"{{ skin.id }}"
{%
if
song.skin_id =
=
skin
.
id
%}
selected
{%
endif
%}
>
{{ skin.name }}
</option>
{% endfor %}
</select>
</div>
<div
class=
"form-field"
>
<p><label
for=
"preview"
>
Preview
</label></p>
<input
type=
"text"
id=
"preview"
value=
"{{song.preview or '0'}}"
name=
"preview"
required
>
</div>
<div
class=
"form-field"
>
<p><label
for=
"volume"
>
Volume
</label></p>
<input
type=
"text"
id=
"volume"
value=
"{{song.volume or '1.0'}}"
name=
"volume"
required
>
</div>
<div
class=
"form-field"
>
<p><label
for=
"maker_id"
>
Maker
</label></p>
<select
name=
"maker_id"
id=
"maker_id"
>
<option
value=
"0"
>
(none)
</option>
{% for maker in makers %}
<option
value=
"{{ maker.id }}"
{%
if
song.maker_id =
=
maker
.
id
%}
selected
{%
endif
%}
>
{{ maker.name }}
</option>
{% endfor %}
</select>
</div>
<button
type=
"submit"
>
Save
</button>
...
...
tools/migrate_db.py
View file @
61e521dd
...
...
@@ -5,7 +5,7 @@ import sqlite3
from
pymongo
import
MongoClient
client
=
MongoClient
()
#
client.drop_database('taiko')
client
.
drop_database
(
'taiko'
)
db
=
client
.
taiko
sqdb
=
sqlite3
.
connect
(
'taiko.db'
)
sqdb
.
row_factory
=
sqlite3
.
Row
...
...
@@ -26,10 +26,10 @@ def migrate_songs():
'enabled'
:
True
if
row
[
'enabled'
]
else
False
,
'category_id'
:
row
[
'category'
],
'type'
:
row
[
'type'
],
'offset'
:
row
[
'offset'
],
'offset'
:
row
[
'offset'
]
or
0
,
'skin_id'
:
row
[
'skin_id'
],
'preview'
:
row
[
'preview'
],
'volume'
:
row
[
'volume'
],
'preview'
:
row
[
'preview'
]
or
0
,
'volume'
:
row
[
'volume'
]
or
1.0
,
'maker_id'
:
row
[
'maker_id'
],
'hash'
:
row
[
'hash'
],
'order'
:
row
[
'id'
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment