Skip to content

Commit

Permalink
chg: [view] Reoganized various imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricbonhomme committed Jan 17, 2025
1 parent 8a6324e commit eac7d9b
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 143 deletions.
6 changes: 3 additions & 3 deletions newspipe/controllers/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import sqlalchemy
from sqlalchemy import func

from .abstract import AbstractController
from newspipe.bootstrap import db
from newspipe.controllers import CategoryController
from newspipe.controllers import FeedController
from newspipe.controllers import CategoryController, FeedController
from newspipe.lib.article_utils import process_filters
from newspipe.models import Article

from .abstract import AbstractController

logger = logging.getLogger(__name__)


Expand Down
15 changes: 4 additions & 11 deletions newspipe/web/views/admin.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
from datetime import datetime

from flask import Blueprint
from flask import flash
from flask import redirect
from flask import render_template
from flask import url_for
from flask_babel import format_timedelta
from flask_babel import gettext
from flask_login import current_user
from flask_login import login_required
from flask import Blueprint, flash, redirect, render_template, url_for
from flask_babel import format_timedelta, gettext
from flask_login import current_user, login_required

from newspipe.controllers import UserController
from newspipe.web.forms import InformationMessageForm
from newspipe.web.forms import UserForm
from newspipe.web.forms import InformationMessageForm, UserForm
from newspipe.web.views.common import admin_permission

admin_bp = Blueprint("admin", __name__, url_prefix="/admin")
Expand Down
30 changes: 14 additions & 16 deletions newspipe/web/views/article.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
from datetime import datetime
from datetime import timedelta

from flask import Blueprint
from flask import flash
from flask import make_response
from flask import redirect
from flask import render_template
from flask import request
from flask import url_for
from datetime import datetime, timedelta

from flask import (
Blueprint,
flash,
make_response,
redirect,
render_template,
request,
url_for,
)
from flask_babel import gettext
from flask_login import current_user
from flask_login import login_required
from flask_login import current_user, login_required

from newspipe.bootstrap import db
from newspipe.controllers import ArticleController
from newspipe.controllers import UserController
from newspipe.controllers import ArticleController, UserController
from newspipe.lib.data import export_json
from newspipe.lib.utils import clear_string
from newspipe.lib.utils import safe_redirect_url
from newspipe.lib.utils import clear_string, safe_redirect_url
from newspipe.web.lib.view_utils import etag_match

articles_bp = Blueprint("articles", __name__, url_prefix="/articles")
Expand Down
14 changes: 3 additions & 11 deletions newspipe/web/views/category.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
from flask import abort
from flask import Blueprint
from flask import flash
from flask import redirect
from flask import render_template
from flask import url_for
from flask import Blueprint, abort, flash, redirect, render_template, url_for
from flask_babel import gettext
from flask_login import current_user
from flask_login import login_required
from flask_login import current_user, login_required

from newspipe.controllers import ArticleController
from newspipe.controllers import CategoryController
from newspipe.controllers import FeedController
from newspipe.controllers import ArticleController, CategoryController, FeedController
from newspipe.lib.utils import safe_redirect_url
from newspipe.web.forms import CategoryForm
from newspipe.web.lib.view_utils import etag_match
Expand Down
15 changes: 8 additions & 7 deletions newspipe/web/views/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
from datetime import datetime
from functools import wraps

from flask import current_app
from flask import Response
from flask import Response, current_app
from flask_login import login_user
from flask_principal import Identity
from flask_principal import identity_changed
from flask_principal import Permission
from flask_principal import RoleNeed
from flask_principal import session_identity_loader
from flask_principal import (
Identity,
Permission,
RoleNeed,
identity_changed,
session_identity_loader,
)

from newspipe.controllers import UserController
from newspipe.lib.utils import default_handler
Expand Down
38 changes: 19 additions & 19 deletions newspipe/web/views/feed.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import logging
from datetime import datetime
from datetime import timedelta
from datetime import datetime, timedelta

import requests.exceptions
from flask import Blueprint
from flask import flash
from flask import make_response
from flask import redirect
from flask import render_template
from flask import request
from flask import url_for
from flask import (
Blueprint,
flash,
make_response,
redirect,
render_template,
request,
url_for,
)
from flask_babel import gettext
from flask_login import current_user
from flask_login import login_required
from flask_paginate import get_page_args
from flask_paginate import Pagination
from flask_login import current_user, login_required
from flask_paginate import Pagination, get_page_args
from werkzeug.exceptions import BadRequest

from newspipe.bootstrap import application
from newspipe.controllers import ArticleController
from newspipe.controllers import CategoryController
from newspipe.controllers import FeedController
from newspipe.controllers import UserController
from newspipe.lib import misc_utils
from newspipe.lib import utils
from newspipe.controllers import (
ArticleController,
CategoryController,
FeedController,
UserController,
)
from newspipe.lib import misc_utils, utils
from newspipe.lib.feed_utils import construct_feed_from
from newspipe.web.forms import AddFeedForm
from newspipe.web.lib.view_utils import etag_match
Expand Down
20 changes: 5 additions & 15 deletions newspipe/web/views/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@
from datetime import datetime

import pytz
from babel.dates import format_datetime
from babel.dates import format_timedelta
from flask import current_app
from flask import flash
from flask import redirect
from flask import render_template
from flask import request
from flask import url_for
from flask_babel import get_locale
from flask_babel import gettext
from flask_login import current_user
from flask_login import login_required
from babel.dates import format_datetime, format_timedelta
from flask import current_app, flash, redirect, render_template, request, url_for
from flask_babel import get_locale, gettext
from flask_login import current_user, login_required

from newspipe.bootstrap import application
from newspipe.controllers import ArticleController
from newspipe.controllers import CategoryController
from newspipe.controllers import FeedController
from newspipe.controllers import ArticleController, CategoryController, FeedController
from newspipe.lib import misc_utils
from newspipe.lib.utils import safe_redirect_url
from newspipe.web.lib.view_utils import etag_match
Expand Down
4 changes: 1 addition & 3 deletions newspipe/web/views/icon.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import base64

from flask import Blueprint
from flask import request
from flask import Response
from flask import Blueprint, Response, request

from newspipe.controllers import IconController
from newspipe.web.lib.view_utils import etag_match
Expand Down
42 changes: 20 additions & 22 deletions newspipe/web/views/session_mgmt.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
import logging
from datetime import datetime

from flask import current_app
from flask import flash
from flask import redirect
from flask import render_template
from flask import request
from flask import session
from flask import url_for
from flask import (
current_app,
flash,
redirect,
render_template,
request,
session,
url_for,
)
from flask_babel import gettext
from flask_login import current_user
from flask_login import login_required
from flask_login import LoginManager
from flask_login import logout_user
from flask_principal import AnonymousIdentity
from flask_principal import identity_changed
from flask_principal import identity_loaded
from flask_principal import Principal
from flask_principal import session_identity_loader
from flask_principal import UserNeed
from flask_login import LoginManager, current_user, login_required, logout_user
from flask_principal import (
AnonymousIdentity,
Principal,
UserNeed,
identity_changed,
identity_loaded,
session_identity_loader,
)
from werkzeug.exceptions import NotFound
from werkzeug.security import generate_password_hash

from newspipe.bootstrap import application
from newspipe.controllers import UserController
from newspipe.notifications import notifications
from newspipe.web.forms import SigninForm
from newspipe.web.forms import SignupForm
from newspipe.web.views.common import admin_role
from newspipe.web.views.common import api_role
from newspipe.web.views.common import login_user_bundle
from newspipe.web.forms import SigninForm, SignupForm
from newspipe.web.views.common import admin_role, api_role, login_user_bundle

Principal(current_app)
# Create a permission with a single Need, in this case a RoleNeed.
Expand Down
9 changes: 3 additions & 6 deletions newspipe/web/views/stats.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from flask import Blueprint
from flask import jsonify
from flask_login import current_user
from flask_login import login_required
from flask import Blueprint, jsonify
from flask_login import current_user, login_required

from newspipe.controllers import ArticleController
from newspipe.controllers import CategoryController
from newspipe.controllers import ArticleController, CategoryController

stats_bp = Blueprint("stats", __name__, url_prefix="/stats")

Expand Down
28 changes: 11 additions & 17 deletions newspipe/web/views/user.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
from flask import Blueprint
from flask import flash
from flask import redirect
from flask import render_template
from flask import request
from flask import url_for
from flask import Blueprint, flash, redirect, render_template, request, url_for
from flask_babel import gettext
from flask_login import current_user
from flask_login import login_required
from flask_paginate import get_page_args
from flask_paginate import Pagination
from flask_login import current_user, login_required
from flask_paginate import Pagination, get_page_args

from newspipe.bootstrap import application
from newspipe.controllers import ArticleController
from newspipe.controllers import BookmarkController
from newspipe.controllers import CategoryController
from newspipe.controllers import FeedController
from newspipe.controllers import UserController
from newspipe.controllers import (
ArticleController,
BookmarkController,
CategoryController,
FeedController,
UserController,
)
from newspipe.lib import misc_utils
from newspipe.lib.data import import_json
from newspipe.lib.data import import_opml
from newspipe.lib.data import import_json, import_opml
from newspipe.web.forms import ProfileForm
from newspipe.web.lib.user_utils import confirm_token

Expand Down
18 changes: 5 additions & 13 deletions newspipe/web/views/views.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import logging
import operator
import sys
from datetime import datetime
from datetime import timedelta

from flask import current_app
from flask import flash
from flask import redirect
from flask import render_template
from flask import request
from flask import url_for
from datetime import datetime, timedelta

from flask import current_app, flash, redirect, render_template, request, url_for
from flask_babel import gettext
from sqlalchemy import desc

from newspipe.bootstrap import application
from newspipe.bootstrap import talisman
from newspipe.controllers import FeedController
from newspipe.controllers import UserController
from newspipe.bootstrap import application, talisman
from newspipe.controllers import FeedController, UserController
from newspipe.web import __version__
from newspipe.web.lib.view_utils import etag_match

Expand Down

0 comments on commit eac7d9b

Please sign in to comment.