Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Video AG Infrastruktur
website
Commits
046db0a5
Commit
046db0a5
authored
8 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Replaced ordering number generation with sql trigger
parent
0b7f0e00
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
db_schema.sql
+2
-1
2 additions, 1 deletion
db_schema.sql
server.py
+2
-5
2 additions, 5 deletions
server.py
templates/index.html
+11
-15
11 additions, 15 deletions
templates/index.html
with
15 additions
and
21 deletions
db_schema.sql
+
2
−
1
View file @
046db0a5
...
@@ -223,7 +223,7 @@ CREATE TABLE IF NOT EXISTS `featured` (
...
@@ -223,7 +223,7 @@ CREATE TABLE IF NOT EXISTS `featured` (
`type`
varchar
(
32
)
NOT
NULL
DEFAULT
''
,
`type`
varchar
(
32
)
NOT
NULL
DEFAULT
''
,
`param`
text
NOT
NULL
DEFAULT
''
,
`param`
text
NOT
NULL
DEFAULT
''
,
`param2`
text
NOT
NULL
DEFAULT
''
,
`param2`
text
NOT
NULL
DEFAULT
''
,
`order`
INTEGER
NO
T
NULL
,
`order`
INTEGER
DEFAUL
T
NULL
,
`visible`
INTEGER
NOT
NULL
DEFAULT
0
,
`visible`
INTEGER
NOT
NULL
DEFAULT
0
,
`deleted`
INTEGER
NOT
NULL
DEFAULT
0
,
`deleted`
INTEGER
NOT
NULL
DEFAULT
0
,
`time_created`
datetime
NOT
NULL
,
`time_created`
datetime
NOT
NULL
,
...
@@ -272,4 +272,5 @@ CREATE VIEW IF NOT EXISTS `courses` AS select * from `courses_data` where (not(`
...
@@ -272,4 +272,5 @@ CREATE VIEW IF NOT EXISTS `courses` AS select * from `courses_data` where (not(`
CREATE
VIEW
IF
NOT
EXISTS
`lectures`
AS
select
`lectures_data`
.
*
from
`lectures_data`
join
`courses_data`
on
(
`courses_data`
.
`id`
=
`course_id`
)
where
(
not
(
`lectures_data`
.
`deleted`
or
`courses_data`
.
`deleted`
));
CREATE
VIEW
IF
NOT
EXISTS
`lectures`
AS
select
`lectures_data`
.
*
from
`lectures_data`
join
`courses_data`
on
(
`courses_data`
.
`id`
=
`course_id`
)
where
(
not
(
`lectures_data`
.
`deleted`
or
`courses_data`
.
`deleted`
));
CREATE
VIEW
IF
NOT
EXISTS
`videos`
AS
select
`videos_data`
.
*
from
`videos_data`
join
`lectures_data`
on
(
`lectures_data`
.
`id`
=
`lecture_id`
)
join
`courses_data`
on
(
`courses_data`
.
`id`
=
`course_id`
)
where
(
not
(
`videos_data`
.
`deleted`
or
`lectures_data`
.
`deleted`
or
`courses_data`
.
`deleted`
));
CREATE
VIEW
IF
NOT
EXISTS
`videos`
AS
select
`videos_data`
.
*
from
`videos_data`
join
`lectures_data`
on
(
`lectures_data`
.
`id`
=
`lecture_id`
)
join
`courses_data`
on
(
`courses_data`
.
`id`
=
`course_id`
)
where
(
not
(
`videos_data`
.
`deleted`
or
`lectures_data`
.
`deleted`
or
`courses_data`
.
`deleted`
));
CREATE
VIEW
IF
NOT
EXISTS
`sorterrorlog`
AS
select
*
from
`sorterrorlog_data`
where
(
not
(
`sorterrorlog_data`
.
`deleted`
));
CREATE
VIEW
IF
NOT
EXISTS
`sorterrorlog`
AS
select
*
from
`sorterrorlog_data`
where
(
not
(
`sorterrorlog_data`
.
`deleted`
));
CREATE
TRIGGER
IF
NOT
EXISTS
featured_unique_order
AFTER
INSERT
ON
featured
FOR
EACH
ROW
BEGIN
UPDATE
featured
SET
`order`
=
(
SELECT
MAX
(
`order`
)
FROM
featured
)
+
1
WHERE
id
=
NEW
.
id
;
END
;
COMMIT
;
COMMIT
;
This diff is collapsed.
Click to expand it.
server.py
+
2
−
5
View file @
046db0a5
...
@@ -327,16 +327,13 @@ def index():
...
@@ -327,16 +327,13 @@ def index():
WHERE streams.active AND (? OR (streams.visible AND courses.visible AND courses.listed AND lectures.visible))
WHERE streams.active AND (? OR (streams.visible AND courses.visible AND courses.listed AND lectures.visible))
'''
,
ismod
())
'''
,
ismod
())
featured
=
query
(
'
SELECT * FROM featured WHERE (? OR visible) ORDER BY `order`
'
,
ismod
())
featured
=
query
(
'
SELECT * FROM featured WHERE (? OR visible) ORDER BY `order`
'
,
ismod
())
newfeatured
=
0
if
featured
:
newfeatured
=
featured
[
-
1
][
'
order
'
]
+
1
featured
=
list
(
filter
(
lambda
x
:
not
x
[
'
deleted
'
],
featured
))
featured
=
list
(
filter
(
lambda
x
:
not
x
[
'
deleted
'
],
featured
))
for
item
in
featured
:
for
item
in
featured
:
if
item
[
'
type
'
]
==
'
courses
'
:
if
item
[
'
type
'
]
==
'
courses
'
:
if
item
[
'
param
'
]
not
in
[
'
title
'
,
'
semester
'
,
'
organizer
'
,
'
subject
'
]:
if
item
[
'
param
'
]
not
in
[
'
title
'
,
'
semester
'
,
'
organizer
'
,
'
subject
'
]:
continue
continue
item
[
'
courses
'
]
=
query
(
'
SELECT * FROM courses WHERE (visible AND listed) AND `%s` = ? ORDER BY `%s`
'
%
(
item
[
'
param
'
],
item
[
'
param
'
]),
item
[
'
param2
'
])
item
[
'
courses
'
]
=
query
(
'
SELECT * FROM courses WHERE (visible AND listed) AND `%s` = ? ORDER BY `%s`
'
%
(
item
[
'
param
'
],
item
[
'
param
'
]),
item
[
'
param2
'
])
return
render_template
(
'
index.html
'
,
latestvideos
=
livestreams
+
latestvideos
,
upcomming
=
upcomming
,
featured
=
featured
,
newfeatured
=
newfeatured
)
return
render_template
(
'
index.html
'
,
latestvideos
=
livestreams
+
latestvideos
,
upcomming
=
upcomming
,
featured
=
featured
)
@app.route
(
'
/course
'
)
@app.route
(
'
/course
'
)
@register_navbar
(
'
Videos
'
,
icon
=
'
film
'
)
@register_navbar
(
'
Videos
'
,
icon
=
'
film
'
)
...
@@ -505,7 +502,7 @@ tabs = {
...
@@ -505,7 +502,7 @@ tabs = {
'
deleted
'
,
'
time_publish
'
,
'
time_expire
'
],
'
deleted
'
,
'
time_publish
'
,
'
time_expire
'
],
[
'
created_by
'
,
'
time_created
'
,
'
time_updated
'
]),
[
'
created_by
'
,
'
time_created
'
,
'
time_updated
'
]),
'
featured
'
:
(
'
featured
'
,
'
id
'
,
[
'
title
'
,
'
text
'
,
'
internal
'
,
'
visible
'
,
'
deleted
'
,
'
param
'
,
'
param2
'
,
'
order
'
],
'
featured
'
:
(
'
featured
'
,
'
id
'
,
[
'
title
'
,
'
text
'
,
'
internal
'
,
'
visible
'
,
'
deleted
'
,
'
param
'
,
'
param2
'
,
'
order
'
],
[
'
created_by
'
,
'
time_created
'
,
'
time_updated
'
,
'
type
'
,
'
order
'
]),
[
'
created_by
'
,
'
time_created
'
,
'
time_updated
'
,
'
type
'
]),
'
perm
'
:
(
'
perm
'
,
'
id
'
,
[
'
type
'
,
'
param1
'
,
'
param2
'
,
'
deleted
'
],
'
perm
'
:
(
'
perm
'
,
'
id
'
,
[
'
type
'
,
'
param1
'
,
'
param2
'
,
'
deleted
'
],
[
'
course_id
'
,
'
lecture_id
'
,
'
video_id
'
,
'
created_by
'
,
'
time_created
'
,
'
time_updated
'
]),
[
'
course_id
'
,
'
lecture_id
'
,
'
video_id
'
,
'
created_by
'
,
'
time_created
'
,
'
time_updated
'
]),
'
sorterrorlog
'
:
(
'
sorterrorlog_data
'
,
'
id
'
,
[
'
deleted
'
],
'
sorterrorlog
'
:
(
'
sorterrorlog_data
'
,
'
id
'
,
[
'
deleted
'
],
...
...
This diff is collapsed.
Click to expand it.
templates/index.html
+
11
−
15
View file @
046db0a5
...
@@ -57,9 +57,9 @@
...
@@ -57,9 +57,9 @@
<div
class=
"btn-group"
>
<div
class=
"btn-group"
>
<button
type=
"button"
class=
"btn btn-default dropdown-toggle"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"false"
>
Neues Panel
<span
class=
"caret"
></span></button>
<button
type=
"button"
class=
"btn btn-default dropdown-toggle"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"false"
>
Neues Panel
<span
class=
"caret"
></span></button>
<ul
class=
"dropdown-menu"
>
<ul
class=
"dropdown-menu"
>
<li><a
href=
"{{ url_for('create', table='featured', title='Neues Panel', type='plain', ref=request.url
, order=newfeatured
) }}"
>
Nur Text
</a></li>
<li><a
href=
"{{ url_for('create', table='featured', title='Neues Panel', type='plain', ref=request.url) }}"
>
Nur Text
</a></li>
<li><a
href=
"{{ url_for('create', table='featured', title='Neues Panel', type='image', ref=request.url
, order=newfeatured
) }}"
>
Text mit Bild
</a></li>
<li><a
href=
"{{ url_for('create', table='featured', title='Neues Panel', type='image', ref=request.url) }}"
>
Text mit Bild
</a></li>
<li><a
href=
"{{ url_for('create', table='featured', title='Neues Panel', type='courses', param='semester', param2='', ref=request.url
, order=newfeatured
) }}"
>
Veranstaltungsliste
</a></li>
<li><a
href=
"{{ url_for('create', table='featured', title='Neues Panel', type='courses', param='semester', param2='', ref=request.url) }}"
>
Veranstaltungsliste
</a></li>
</ul>
</ul>
</div>
</div>
</li>
</li>
...
@@ -79,7 +79,6 @@
...
@@ -79,7 +79,6 @@
{{ moderator_editor(('featured',item.id,'title'), item.title) }} {{ moderator_checkbox(('featured',item.id,'visible'), item.visible) }}
{{ moderator_editor(('featured',item.id,'title'), item.title) }} {{ moderator_checkbox(('featured',item.id,'visible'), item.visible) }}
{% if ismod() %}
{% if ismod() %}
<div
class=
"btn-group pull-right"
role=
"group"
>
<div
class=
"btn-group pull-right"
role=
"group"
>
{% if (loop.first or featured[loop.index0-1].order != item.order) and (loop.last or featured[loop.index0+1].order != item.order) %}
{% if not loop.first %}
{% if not loop.first %}
<a
class=
"btn btn-default"
href=
"{{ url_for('edit', **{'featured.'+item.id|string+'.order': featured[loop.index0-1].order, 'featured.'+featured[loop.index0-1].id|string+'.order': item.order, 'ref': request.url})}}"
><span
class=
"glyphicon glyphicon-arrow-up"
></span></a>
<a
class=
"btn btn-default"
href=
"{{ url_for('edit', **{'featured.'+item.id|string+'.order': featured[loop.index0-1].order, 'featured.'+featured[loop.index0-1].id|string+'.order': item.order, 'ref': request.url})}}"
><span
class=
"glyphicon glyphicon-arrow-up"
></span></a>
{% else %}
{% else %}
...
@@ -90,9 +89,6 @@
...
@@ -90,9 +89,6 @@
{% else %}
{% else %}
<button
class=
"btn btn-default disabled"
><span
class=
"glyphicon glyphicon-arrow-down"
></span></button>
<button
class=
"btn btn-default disabled"
><span
class=
"glyphicon glyphicon-arrow-down"
></span></button>
{% endif %}
{% endif %}
{% else %}
<a
class=
"btn btn-default"
data-toggle=
"tooltip"
title=
"Sortierung reparieren"
href=
"{{ url_for('edit', **{'featured.'+item.id|string+'.order': newfeatured, 'ref': request.url})}}"
><span
class=
"glyphicon glyphicon-sort-by-attributes"
></span></a>
{% endif %}
{{ moderator_delete(['featured',item.id,'deleted']) }}
{{ moderator_delete(['featured',item.id,'deleted']) }}
</div>
</div>
{% endif %}
{% endif %}
...
...
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