1 # MediaGoblin for LibrePlanet
2 # Copyright (C) 2015 David Thompson <davet@gnu.org>
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 from mediagoblin
import mg_globals
18 from mediagoblin
.db
.models
import MediaEntry
19 from mediagoblin
.db
.util
import media_entries_for_tag_slug
20 from mediagoblin
.tools
.pagination
import Pagination
21 from mediagoblin
.tools
.response
import render_to_response
22 from mediagoblin
.decorators
import uses_pagination
24 def type_listing(type, title
, request
, page
):
25 cursor
= MediaEntry
.query
.\
26 filter(MediaEntry
.media_type
== type).\
27 order_by(MediaEntry
.created
.desc())
29 pagination
= Pagination(page
, cursor
)
30 media_entries
= pagination()
32 return render_to_response(
34 'libreplanet/listing.html',
36 'media_entries': media_entries
,
37 'pagination': pagination
})
41 def image_listing(request
, page
):
42 return type_listing(u
'mediagoblin.media_types.image', 'Photos', request
, page
)
45 def video_listing(request
, page
):
46 return type_listing(u
'mediagoblin.media_types.video', 'Videos', request
, page
)