9e50146596b6959f6216cc38710d032dabcc7889
[mediagoblin-libreplanet.git] / mediagoblin_libreplanet / lp_helper.py
1 # MediaGoblin for LibrePlanet
2 #
3 # Based on code from MediaGoblin
4 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
5 # Copyright (C) 2017 Andrew Engelbrecht <andrew@fsf.org>
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
16 #
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 def media_entries_for_tag_slug_case_insensitive(dummy_db, tag_slug):
21 return MediaEntry.query \
22 .join(MediaEntry.tags_helper) \
23 .join(MediaTag.tag_helper) \
24 .filter(
25 (MediaEntry.state == u'processed')
26 & (Tag.slug.lower() == tag_slug.lower()))
27