|
5 | 5 | from pprint import pprint as pp |
6 | 6 |
|
7 | 7 | from flask import ( |
8 | | - Blueprint, flash, g, redirect, render_template, request, url_for |
| 8 | + Blueprint, flash, g, render_template, request |
9 | 9 | ) |
10 | 10 |
|
11 | 11 | from ..auth import api_access_required |
12 | 12 | from ..reddit import get_reddit_object |
13 | | -from .search import perform_search, check_form |
14 | 13 |
|
15 | 14 | bp = Blueprint('list_subreddits', __name__) |
16 | 15 |
|
@@ -50,14 +49,10 @@ def get_subs(token, get_latest, sort_by, sort_reverse): |
50 | 49 |
|
51 | 50 | if result['status'] == 'error': |
52 | 51 | return result |
53 | | - else: |
54 | | - reddit = result['data'] |
55 | 52 |
|
| 53 | + reddit = result['data'] |
56 | 54 | results = [] |
57 | 55 |
|
58 | | - print('fetching items: ') |
59 | | - print('-'*200) |
60 | | - |
61 | 56 | for subreddit in reddit.user.subreddits(limit=None): |
62 | 57 |
|
63 | 58 | subreddit.id # trigger loading |
@@ -112,10 +107,7 @@ def check_form(form): |
112 | 107 | else: |
113 | 108 | options['sort_by'] = 'subscribers' |
114 | 109 |
|
115 | | - if 'sort_order' in form and form['sort_order'] == 'desc': |
116 | | - options['sort_reverse'] = True |
117 | | - else: |
118 | | - options['sort_reverse'] = False |
| 110 | + options['sort_reverse'] = 'sort_order' in form and form['sort_order'] == 'desc' |
119 | 111 |
|
120 | 112 | # if we are not getting the latest post, we can't sort by the time of the last post |
121 | 113 | if not options['get_latest'] and form['sort_by'] == 'last_post': |
|
0 commit comments