Film.name, Film.year, Review.text, Review.id, Review.rating).join(Review, Film.id == Review.film_id).filter( Review.user_id == user_id).all()) return self.render('user_page.html', review_list=user_reviews) @expose('/review/<review_id>') def preview_review(self, review_id: int) -> Response: with create_session() as session: review = session.query(Review).filter(Review.id == review_id).one() return self.render('review_edit_form.html', review=review) @expose('/update_review/<review_id>') def update_review(self, review_id: int) -> Response: with create_session() as session: new_review = request.args.get('review_text') review = session.query(Review).filter(Review.id == review_id).one() review.text = new_review return redirect(url_for('users.user_page', user_id=review.user_id), code=302) admin = Admin( app, name='filmrating admin panel', template_mode='bootstrap3', index_view=CustomIndexView(name='Старт', url='/'), ) with create_session() as s: admin.add_view(ModelView(Film, s, name='Фильмы')) admin.add_view(ReviewsView(name='Пользователи', endpoint='users'))
with app.app_context(): # extensions sql_storage = SQLAStorage(db=db) login_manager = LoginManager(app) db.create_all() # create test user if not exists user = User.query.filter_by(username="******").first() if user is None: user = User("testuser", email="*****@*****.**") db.session.add(user) db.session.commit() blog_engine = BloggingEngine(app, sql_storage) admin = Admin(app, name="Flask-Blogging", template_mode='bootstrap3') Post = sql_storage.post_model Tag = sql_storage.tag_model admin.add_view(ModelView(Post, db.session)) admin.add_view(ModelView(Tag, db.session)) admin.add_view(ModelView(User, db.session)) @login_manager.user_loader @blog_engine.user_loader def load_user(user_id): user = User.query.filter_by(id=user_id).first() print(user_id, user.get_name()) return user index_template = """ <!DOCTYPE html> <html>
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' bootstrap = Bootstrap(app) db = SQLAlchemy(app) login_manager = LoginManager() login_manager.init_app(app) login_manager.login_view = 'login' from models import * from forms import * admin = Admin(app, index_view=MyAdminIndexView(name="Home", template='admin/index.html')) admin.add_view(ModelView(user, db.session, name="User")) admin.add_view(ModelView(Feedback, db.session, name="Feedbacks")) admin.add_view(ModelView(Quiz, db.session)) admin.add_view(RuleView(Problems, db.session)) admin.add_view(ModelView(Category, db.session)) admin.add_view(ModelView(Sub_Category, db.session, name="SubCategory")) def init_db(): db.init_app(app) db.drop_all() db.create_all() def get_auth(state=None, token=None): if token:
('6', 'Perfil Incompatível')], 'pasta': [('0', 'a definir'), ('1', 'Saúde'), ('2', 'Profissionalização/Capacitação'), ('3', 'Acompanhamento Pedagócico'), ('4', 'Lazer/Cultura e Esporte'), ('5', 'Doação')], 'subpasta': [('0', 'Menor Aprendiz'), ('1', 'Estágio Nível Médio'), ('2', 'Outros')] } edit_template = 'edit_user.html' create_template = 'create_user.html' admin.add_view( JurisdicionadoView(Jurisdicionado, db.session, category="Jurisdicionado")) admin.add_view(ModelView(Responsavel, db.session, category="Jurisdicionado")) admin.add_view(DemandaView(Demanda, db.session, category="Jurisdicionado")) admin.add_view(ModelView(Parceiro, db.session, category="Jurisdicionado")) admin.add_view(ModelView(Vinculacao, db.session, category="Jurisdicionado")) admin.add_view(ModelView(Voluntario, db.session, category="Pessoa Fisica")) admin.add_view( ModelView(DadoProfissional, db.session, category="Pessoa Fisica")) admin.add_view(ModelView(Atuacaopf, db.session, category="Pessoa Fisica")) admin.add_view(ModelView(Vinculapf, db.session, category="Pessoa Fisica")) admin.add_view(ModelView(Juridico, db.session, category="Pessoa Juridica")) admin.add_view( ModelView(RepresentanteLegal, db.session, category="Pessoa Juridica")) admin.add_view(ModelView(Atuacaopj, db.session, category="Pessoa Juridica")) admin.add_view(ModelView(Vinculapj, db.session, category="Pessoa Juridica"))
from seshat import admin, db from flask_admin.contrib.sqla import ModelView from seshat.models import Author, Book, User, Genre, Language, Subject, Tag, Tagging admin.add_view(ModelView(Author, db.session)) admin.add_view(ModelView(Book, db.session)) admin.add_view(ModelView(User, db.session)) admin.add_view(ModelView(Genre, db.session)) admin.add_view(ModelView(Language, db.session)) admin.add_view(ModelView(Subject, db.session)) admin.add_view(ModelView(Tag, db.session)) admin.add_view(ModelView(Tagging, db.session))
from flask import Flask from flask import Flask from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user from sqlalchemy.exc import * from flask_sqlalchemy import SQLAlchemy from flask_admin import Admin from flask_admin.contrib.sqla import ModelView app = Flask(__name__) app.config.from_pyfile('config.py') from dashboard.admin.model import * from dashboard.admin.view import index db.init_app(app) administrator = Admin(app, name='Control Panel') administrator.add_view(ModelView(Student, db.session)) #administrator.add_view(ModelView(Guardian,db.session)) app.register_blueprint(admin.view.index)
mail_handler.setLevel(logging.ERROR) app.logger.addHandler(mail_handler) if not os.path.exists('logs'): os.mkdir('logs') file_handler = RotatingFileHandler('logs/microblog.log', maxBytes=10240, backupCount=10) file_handler.setFormatter( logging.Formatter( '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]' )) file_handler.setLevel(logging.INFO) app.logger.addHandler(file_handler) app.logger.setLevel(logging.INFO) app.logger.info('Shop startup') from app import routes, models, errors ###ADMIN### from flask_admin import Admin from flask_admin.contrib.sqla import ModelView from app.models import Post, Product, User admin = Admin(app) admin.add_view(ModelView(Post, db.session)) admin.add_view(ModelView(User, db.session)) admin.add_view(ModelView(Product, db.session))
db.ForeignKey('supplier.id'), nullable=False) id = db.Column(db.Integer, primary_key=True) last_name = db.Column(db.String(30), nullable=False) first_name = db.Column(db.String(30), nullable=False) email = db.Column(db.String(255), nullable=False, unique=True) password = db.Column(db.String(255), nullable=False) is_inactive = db.Column(db.Boolean, nullable=True) def check_password(self, password): return check_password_hash(self.password, password) @event.listens_for(SupplierUser.password, 'set', retval=True) def hash_staff_password(target, value, oldvalue, initiator): if value != oldvalue: return generate_password_hash(value) return value class ProductAdminView(ModelView): form_columns = ['id', 'name', 'thickness', 'qty', 'size', 'box_size'] column_list = ['id', 'name', 'thickness', 'qty', 'size', 'box_size'] admin.add_view(ModelView(Staff, db.session, endpoint="staffview")) admin.add_view(ProductAdminView(Product, db.session)) admin.add_view(SupplierAdminView(Supplier, db.session)) admin.add_view(ModelView(SupplierUser, db.session))
class MyAdminIndexView(AdminIndexView): def is_accessible(selfself): Session = sessionmaker(bind=engine) s = Session() statut = s.query(Utilisateur.status).filter( Utilisateur.username == session['username']).first()[0] return session.get('logged_in') and statut == 'administrateur' db = SQLAlchemy(app) admin = Admin(app, index_view=MyAdminIndexView()) admin.add_view(MyModel(Utilisateur, db.session)) admin.add_view(ModelView(RaphMail, db.session)) admin.add_view(ModelView(Matiere, db.session)) admin.add_view(ModelView(Tchat, db.session)) admin.add_view(ModelView(Fichier, db.session)) admin.add_view(ModelView(Like, db.session)) admin.add_view(ModelView(Dislike, db.session)) ##Upload def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS @app.route('/uploads/<filename>') def uploaded_file(filename):
from flask_admin.contrib.sqla import ModelView admin.add_view(ModelView(Artist, db.session)) admin.add_view(ModelView(Album, db.session)) admin.add_view(ModelView(Tag, db.session))
admin = Admin(app) class Person(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20)) pets = db.relationship('Pet', backref='owner') class Pet(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20)) owner_id = db.Column(db.Integer, db.ForeignKey('person.id')) admin.add_view(ModelView(Person, db.session)) admin.add_view(ModelView(Pet, db.session)) if __name__ == '__main__': app.run(debug=True) ''' Para inserir uma person no banco: gustavo = Person(name='Gustavo') db.session.add(gustavo) Para inserir um pet: spot = Pet(name='Spot', owner=gustavo) (backref='owner') db.session.add(spot) Para imprimir os pets de uma person:
@app.route('/populate') def populate(): x=[1,2,3,4,12,13,14,23,24,34,123,124,134,234,1234] counter=1 for i in pop: for j in pop[i]: for k in range(1,6): p="this is question "+str(k) temp=quizdata(answer=random.choice(x),question=p,category=i,sub_category=j,question_number=k,option_1="this is option 1",option_2="this is option 2",option_3="this is option 3",option_4="this is option 4") db.session.add(temp) db.session.commit() counter+=1 admin.add_view(ModelView(User,db.session)) admin.add_view(ModelView(quizdata,db.session)) @app.route('/evaluate/<cat>/<subcat>',methods=['GET', 'POST']) def evaluate(cat,subcat): temp=User.query.filter_by(username=current_user.username,category=cat,sub_category=subcat).first() quiz_tempi=quizdata.query.filter_by(category=cat,sub_category=subcat).all() skore=0 for i in range(1,6): quiz_temp=quizdata.query.filter_by(category=cat,sub_category=subcat,question_number=i).first() if(''.join(temp.question1.split(","))==quiz_temp.answer): skore+=1 if(''.join(temp.question2.split(","))==quiz_temp.answer): skore+=1 if(''.join(temp.question3.split(","))==quiz_temp.answer):
os.path.join(app.root_path, db_file_name) app.config['TEST_SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \ os.path.join(app.root_path, test_db_file_name) app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SECRET_KEY'] = 'fsdfsdfdsf' login_manager = LoginManager() login_manager.init_app(app) login_manager.login_view = 'login' import user from models import Booking, User as UserModel, Car, db from admin_auth import MyAdminIndexView admin = Admin(app, name='Electric Care Hire', index_view=MyAdminIndexView(), template_mode='bootstrap3') admin.add_view(user.MyModelView(UserModel, db.session)) admin.add_view(user.MyModelView(Car, db.session)) admin.add_view(ModelView(Booking, db.session)) db.create_all() from core import core from booking import booking from user import user app.register_blueprint(core) app.register_blueprint(booking) app.register_blueprint(user) csrf = CSRFProtect(app)
from flask_admin import Admin from src.controller.blueprints.lost_item import lostitem_blueprint from src.controller.blueprints.user import user_blueprint from src.setup import app, db from flask_admin.contrib.sqla import ModelView from src.model import User, Vehicle, Laptop, CellPhone, SearchHistory app.config['FLASK_ADMIN_SWATCH'] = 'cerulean' admin = Admin(app, name='choraiinfo', template_mode='bootstrap3') admin.add_view(ModelView(User, db.session)) admin.add_view(ModelView(Vehicle, db.session)) admin.add_view(ModelView(Laptop, db.session)) admin.add_view(ModelView(CellPhone, db.session)) admin.add_view(ModelView(SearchHistory, db.session)) app.register_blueprint(user_blueprint, url_prefix="/user") app.register_blueprint(lostitem_blueprint, url_prefix="/item")
db.session.commit() id_res = db.session.query(func.count(Reservation.id)).scalar() new_seat_reserved = SeatReserved(id_screening=scr_id, id_reservation=id_res, number=seat, row=row) db.session.add(new_seat_reserved) db.session.commit() return render_template('succed.html') info = Spectacle.query.filter_by(id=id_spec).first() date_info = Screening.query.filter_by(id_spectacle=id_spec).first() return render_template('reservation.html', info=info, date_info=date_info) #Admin admin.add_view(ModelView(Administrators, db.session)) admin.add_view(ModelView(Theater, db.session)) admin.add_view(ModelView(Auditorium, db.session)) admin.add_view(ModelView(Spectacle, db.session)) admin.add_view(ModelView(Screening, db.session)) admin.add_view(ModelView(Reservation, db.session)) admin.add_view(ModelView(SeatReserved, db.session)) if __name__ == '__main__': app.run(debug=True)
"Application/static/vendor_documents") Session = db.session admin = Admin(app, "", template_mode="bootstrap3", index_view=AdminHomeView()) admin.add_view(ShopView(db.Shop, Session)) admin.add_view(FileAdmin(path, name="Vendor Documents")) admin.add_view(CustomerView(db.Customer, Session)) admin.add_view( CategoryView(db.Category, Session, category="Product Categories")) admin.add_view( SubCategoryView(db.SubCategory, Session, category="Product Categories")) admin.add_view(BrandView(db.Brand, Session)) admin.add_view(ProductView(db.Product, Session, category="Products")) admin.add_view( ProductDetailsView(db.ProductDetails, Session, category="Products")) admin.add_view(ModelView(db.Order, Session)) admin.add_view(ModelView(db.Payment, Session, category="Payments")) admin.add_sub_category("Payment Methods", "Payments") admin.add_view(ModelView(db.MobileMoney, Session, category="Payment Methods")) admin.add_view(ModelView(db.Visa, Session, category="Payment Methods")) admin.add_view( ModelView(db.CashOnDelivery, Session, category="Payment Methods")) admin.add_view(ModelView(db.Delivery, Session, category="Deliveries")) admin.add_view(ModelView(db.DeliveryDetails, Session, category="Deliveries")) admin.add_view(ModelView(db.Stock, Session, category="Stock&Sales Tracking")) admin.add_view(ModelView(db.Sales, Session, category="Stock&Sales Tracking")) admin.add_view(
from bot_db.bot_db import db, Schedule, Queries migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) class Statistics(BaseView): 'Class and view for the "Statistics" admin page' @expose('/') def statistics(self): return self.render('statnew.html') admin.add_view(ModelView(Schedule, db.session)) admin.add_view(ModelView(Queries, db.session)) admin.add_view(Statistics(name='Statistics')) @app.route('/admin') def admin_panel(): 'view for main admin page' return render_template('admin/index.html') @app.route('/admin/schedule') def admin_schedules(): 'view for the "Schedule" admin page' return render_template('schedules.html')
if current_user.is_authenticated: # permission denied os.abort(403) else: # login return redirect(url_for('regloginpage', next=request.url)) class CKTextAreaWidget(TextArea): def __call__(self, field, **kwargs): if kwargs.get('class'): kwargs['class'] += ' ckeditor' else: kwargs.setdefault('class', 'ckeditor') return super(CKTextAreaWidget, self).__call__(field, **kwargs) class CKTextAreaField(TextAreaField): widget = CKTextAreaWidget() class MyCommentModel(ModelView): extra_js = ['//cdn.ckeditor.com/4.6.0/standard/ckeditor.js'] form_overrides = {'content': CKTextAreaField} admin.add_view(MyUserModel(User, db.session)) admin.add_view(MyCommentModel(Comment, db.session)) admin.add_view(ModelView(Image, db.session))
#Для подтверждения отправки закака @app.route('/ordered/') def ordered(): return render_template('ordered.html') #просили добавить админку, но тут нет контроля доступа class MyUserView(ModelView): # Настройка общего списка column_exclude_list = ['password_hash'] # убрать из списка одно или несколько полей column_searchable_list = ['mail'] # добавить поиск по полям #column_filters = ['country'] # добавить фильтр по полям # Права на CRUD операции can_create = False can_edit = False can_delete = False # Лимит записей на страницу page_size = 50 admin = Admin(app) admin.add_view(MyUserView(User, db.session)) admin.add_view(ModelView(Category, db.session)) admin.add_view(ModelView(Meal, db.session)) admin.add_view(ModelView(Order, db.session))
from watchlist.models import Article, Movie, User from watchlist import admin, db from flask_admin.contrib.sqla import ModelView class UserView(ModelView): """docstring for UserView""" can_create = False can_edit = False can_delete = False column_exclude_list = ['password_hash'] column_editable_list = ['username'] admin.add_view(UserView(User, db.session, name="用户管理")) admin.add_view(ModelView(Article, db.session, name="文章管理")) admin.add_view(ModelView(Movie, db.session, name="电影管理"))
self.info = info def __repr__(self): return f'<{self.name}>' db.create_all() db.session.commit() # ______________________________________________________________________ # new_user = Fxt_User(email='*****@*****.**', password=f'{os.getenv("WEB_PASSWORD")}') # db.session.add(new_user) # db.session.commit() # ______________________________________________________________________ admin.add_view(ModelView(Fxt_Settings, db.session)) # ______________________________________________________________________ @login_manager.user_loader def load_user(user_id): return Fxt_User.query.get(int(user_id)) # ______________________________________________________________________ @app.route('/', methods=['GET']) @login_required def index(): return '...so far so good!'
from flask_admin.contrib.sqla import ModelView from .models import db, LoginUser, ProxyManager from myproject.framework._globals import get_globals_object admin = get_globals_object("admin") admin.add_view(ModelView(ProxyManager, session=db.session, name="代理")) admin.add_view(ModelView(LoginUser, session=db.session, name="用户信息"))
id_type = Column(Integer, primary_key=True) type_name = Column(String) type_protocol = Column(String) type_desc = Column(String) @serializable class TReleasedDatas(DB.Model): __tablename__ = "t_released_datas" __table_args__ = {"schema": current_app.config["APP_SCHEMA_NAME"]} id_data_release = Column(Integer, primary_key=True) id_type = Column(Integer, ForeignKey("gn_biodivterritory.bib_datas_types.id_type")) data_name = Column(String) data_desc = Column(Text) data_url = Column(String) data_type = relationship(BibDatasTypes, lazy="select") def __repr__(self): return self.data_name admin.add_view( ModelView(BibDatasTypes, DB.session, category="Données", name="Types de données")) admin.add_view( ModelView(TReleasedDatas, DB.session, category="Données", name="Données"))
app = Flask(__name__) bootstrap = Bootstrap(app) app.config.from_pyfile('config.py') app.register_blueprint(sse, url_prefix='/stream') app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:[email protected]:3308/Flask_test' app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True # 设置每次请求结束后会自动提交数据库中的改动 app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True # app.nginx['SQLALCHEMY_ECHO'] = True # 查询时会显示原始SQL语句 db = SQLAlchemy(app) # flask admin 主题 app.config['FLASK_ADMIN_SWATCH'] = 'cerulean' admin = Admin(app, name='microblog', template_mode='bootstrap3') admin.add_view(UserAdmin(db.session, name='用户表')) admin.add_view(ModelView(Host, db.session)) admin.add_view(ModelView(DB, db.session)) def check_login(func): """验证登陆装饰器""" @functools.wraps(func) # 修改内存函数,防止当前装饰器取修改被装饰函数属性 def wrapper(*args, **kwargs): name = session.get('username') if not name: return redirect(url_for('login')) return func(*args, **kwargs) return wrapper
from myapp import admin, db from flask_admin.contrib.sqla import ModelView from myapp.models import Users, Jobs from flask import redirect, url_for, flash from flask_login import current_user from flask_admin.menu import MenuLink class MyView(ModelView): def is_accessible(self): if current_user.is_authenticated and current_user.is_admin: return True else: return False def inaccessible_callback(self, name, **kwargs): flash('You are not authorized for this view', 'danger') return redirect(url_for("main.home")) admin.add_view(MyView(Users, db.session)) admin.add_link(MenuLink(name='Search', url='/')) admin.add_link(MenuLink('Logout', url='/logout')) admin.add_view(ModelView(Jobs, db.session))
id = db.Column(db.Integer, primary_key=True) data = db.Column("Data", DateTime, default=datetime.now()) pajamos = db.Column("Pajamos", db.Boolean) suma = db.Column("Vardas", db.Integer) vartotojas_id = db.Column(db.Integer, db.ForeignKey("vartotojas.id")) vartotojas = db.relationship("Vartotojas", lazy=True) class ManoModelView(ModelView): def is_accessible(self): return current_user.is_authenticated and current_user.el_pastas == "*****@*****.**" admin = Admin(app) admin.add_view(ManoModelView(Vartotojas, db.session)) admin.add_view(ModelView(Irasas, db.session)) @login_manager.user_loader def load_user(vartotojo_id): db.create_all() return Vartotojas.query.get(int(vartotojo_id)) @app.route("/registruotis", methods=['GET', 'POST']) def registruotis(): db.create_all() if current_user.is_authenticated: return redirect(url_for('index')) form = forms.RegistracijosForma() if form.validate_on_submit():
return f'User {self.username}' class Comments(db.Model): __tablename__ = 'comments' id = db.Column(db.Integer, primary_key=True) comment = db.Column(db.String(250)) posted = db.Column(db.DateTime, default=datetime.utcnow) posts_id = db.Column(db.Integer, db.ForeignKey("posts.id")) # def save_comment(self): # db.session.add(self) # db.session.commit() def __repr__(self): return f'User {self.username}' class Subscription(db.Model): __tablename__ = 'subscription' id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(250)) posted = db.Column(db.DateTime, default=datetime.utcnow) admin.add_view(ModelView(User, db.session)) admin.add_view(ModelView(Posts, db.session)) admin.add_view(ModelView(Comments, db.session))
# SQLALCHEMY_DATABASE_URI = 'postgresql://*****:*****@localhost/blog' SQLALCHEMY_DATABASE_URI = 'sqlite:///test.db' BABEL_TRANSLATION_DIRECTORIES = os.path.abspath( os.path.join( os.path.dirname(__file__), os.pardir, 'flask_maple', 'translations')) app = Flask(__name__) app.config.from_object(config) db.init_app(app) admin = Admin(name='devops', template_mode='bootstrap3') for model in [User, Group]: admin.add_view(ModelView(model, db.session, category='user')) admin.init_app(app) cli = FlaskGroup(add_default_commands=False, create_app=lambda r: app) cli.add_command(run_command) @cli.command('shell', short_help='Starts an interactive shell.') def shell_command(): ctx = current_app.make_shell_context() interact(local=ctx) @cli.command() def runserver(): app.run()
id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(30), unique=True) email = db.Column(db.String(80), unique=True) phone_num = db.Column(db.String(30), unique=True) branch = db.Column(db.String(30)) password = db.Column(db.String(30)) def __init__(self, username, email, password, phone_num, branch): self.username = username self.email = email self.phone_num = phone_num self.branch = branch self.password = password admin.add_view(ModelView(User, db.session)) @app.route("/") def index(): return render_template("public/index.html") @app.route("/signup", methods=['GET', 'POST']) def index1(): if request.method == 'POST': username = request.values.get('username') email = request.values.get('email') password = request.values.get('password') branch = request.values.get('branch') phone_num = request.values.get('phone_num')
Description: In User Settings Editgn FilePath: \2011cw2\app\views.py ''' from flask import render_template, request, redirect, flash, url_for, make_response, session from app import app, db ,admin from .forms import UserForm,ArticleForm from .models import User,Article,Category,collect_article,Comment,CommentReply from werkzeug.utils import secure_filename from flask_admin.contrib.sqla import ModelView from datetime import datetime import logging import os import uuid admin.add_view(ModelView(User, db.session)) admin.add_view(ModelView(Article, db.session)) admin.add_view(ModelView(Comment, db.session)) admin.add_view(ModelView(CommentReply, db.session)) admin.add_view(ModelView(Category, db.session)) try: from urlparse import urlparse, urljoin except ImportError: from urllib.parse import urlparse, urljoin def is_safe_url(target): ref_url = urlparse(request.host_url) test_url = urlparse(urljoin(request.host_url, target)) return test_url.scheme in ('http', 'https') and ref_url.netloc == test_url.netloc