added missing imports in helper file
[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 from mediagoblin.db.models import MediaEntry, Tag, MediaTag
21
22 def media_entries_for_tag_slug_case_insensitive(dummy_db, tag_slug):
23 return MediaEntry.query \
24 .join(MediaEntry.tags_helper) \
25 .join(MediaTag.tag_helper) \
26 .filter(
27 (MediaEntry.state == u'processed')
28 & (Tag.slug.lower() == tag_slug.lower()))
29