mirror of
https://github.com/fastogt/fastocloud_admin.git
synced 2025-03-09 23:38:52 +00:00
Review
This commit is contained in:
parent
6f7ecd9a4e
commit
4b1911695f
6 changed files with 26 additions and 26 deletions
|
@ -3,7 +3,6 @@ import struct
|
|||
import json
|
||||
import threading
|
||||
import select
|
||||
import zlib
|
||||
|
||||
from datetime import datetime
|
||||
from app.client.client_constants import Commands, ClientStatus
|
||||
|
|
|
@ -3,7 +3,7 @@ from flask_babel import lazy_gettext
|
|||
from wtforms.fields import StringField, FieldList, IntegerField, FormField, FloatField
|
||||
from wtforms.validators import InputRequired, Length, NumberRange
|
||||
|
||||
from app.constants import MIN_URL_LENGTH, MAX_URL_LENGTH, MIN_ALPHA, MAX_ALPHA, MIN_PATH_LENGTH, MAX_PATH_LENGTH
|
||||
import app.constants as constants
|
||||
from app.common_entries import Rational, Size, Logo, InputUrls, InputUrl, OutputUrls, OutputUrl, HostAndPort
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ class UrlForm(Form):
|
|||
validators=[InputRequired()], render_kw={'readonly': 'true'})
|
||||
uri = StringField(lazy_gettext(u'Url:'),
|
||||
validators=[InputRequired(),
|
||||
Length(min=MIN_URL_LENGTH, max=MAX_URL_LENGTH)])
|
||||
Length(min=constants.MIN_URL_LENGTH, max=constants.MAX_URL_LENGTH)])
|
||||
|
||||
|
||||
class InputUrlForm(UrlForm):
|
||||
|
@ -33,7 +33,7 @@ class InputUrlsForm(Form):
|
|||
class OutputUrlForm(UrlForm):
|
||||
http_root = StringField(lazy_gettext(u'Http root:'),
|
||||
validators=[InputRequired(),
|
||||
Length(min=MIN_PATH_LENGTH, max=MAX_PATH_LENGTH)],
|
||||
Length(min=constants.MIN_PATH_LENGTH, max=constants.MAX_PATH_LENGTH)],
|
||||
render_kw={'readonly': 'true'})
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ class LogoForm(Form):
|
|||
x = IntegerField(lazy_gettext(u'Pos x:'), validators=[InputRequired()])
|
||||
y = IntegerField(lazy_gettext(u'Pos y:'), validators=[InputRequired()])
|
||||
alpha = FloatField(lazy_gettext(u'Alpha:'),
|
||||
validators=[InputRequired(), NumberRange(MIN_ALPHA, MAX_ALPHA)])
|
||||
validators=[InputRequired(), NumberRange(constants.MIN_ALPHA, constants.MAX_ALPHA)])
|
||||
|
||||
def get_data(self) -> Logo:
|
||||
logo = Logo()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from mongoengine import EmbeddedDocument, StringField
|
||||
from app.constants import DEFAULT_LOCALE
|
||||
import app.constants as constants
|
||||
|
||||
|
||||
class Settings(EmbeddedDocument):
|
||||
locale = StringField(default=DEFAULT_LOCALE)
|
||||
locale = StringField(default=constants.DEFAULT_LOCALE)
|
||||
|
|
|
@ -5,7 +5,7 @@ from flask_mail import Message
|
|||
from flask_babel import gettext
|
||||
from itsdangerous import SignatureExpired, URLSafeTimedSerializer
|
||||
|
||||
from app.constants import AVAILABLE_LOCALES_PAIRS, DEFAULT_LOCALE, AVAILABLE_LOCALES
|
||||
import app.constants as constants
|
||||
from app.utils.utils import is_valid_email
|
||||
from app import app, mail, login_manager, babel
|
||||
from app.home.user_loging_manager import User, login_user_wrap
|
||||
|
@ -29,6 +29,7 @@ def send_email(email: str, subject: str, message: str):
|
|||
|
||||
def post_login(form: SigninForm):
|
||||
if not form.validate_on_submit():
|
||||
flash_error(form.errors)
|
||||
return render_template('home/login.html', form=form)
|
||||
|
||||
check_user = User.objects(email=form.email.data).first()
|
||||
|
@ -58,7 +59,7 @@ class HomeView(FlaskView):
|
|||
self._confirm_link_generator = URLSafeTimedSerializer(app.config['SECRET_KEY'])
|
||||
|
||||
def index(self):
|
||||
languages = AVAILABLE_LOCALES_PAIRS
|
||||
languages = constants.AVAILABLE_LOCALES_PAIRS
|
||||
return render_template('index.html', languages=languages)
|
||||
|
||||
@route('/robots.txt')
|
||||
|
@ -82,8 +83,8 @@ class HomeView(FlaskView):
|
|||
return render_template('contact.html', form=form)
|
||||
|
||||
@route('/language/<language>')
|
||||
def set_language(self, language=DEFAULT_LOCALE):
|
||||
founded = next((x for x in AVAILABLE_LOCALES if x == language), None)
|
||||
def set_language(self, language=constants.DEFAULT_LOCALE):
|
||||
founded = next((x for x in constants.AVAILABLE_LOCALES if x == language), None)
|
||||
if founded:
|
||||
session['language'] = founded
|
||||
|
||||
|
@ -130,6 +131,7 @@ class HomeView(FlaskView):
|
|||
form = SignupForm()
|
||||
if request.method == 'POST':
|
||||
if not form.validate_on_submit():
|
||||
flash_error(form.errors)
|
||||
return render_template('home/register.html', form=form)
|
||||
|
||||
email = form.email.data
|
||||
|
@ -178,7 +180,7 @@ def get_locale():
|
|||
# otherwise try to guess the language from the user accept
|
||||
# header the browser transmits. We support de/fr/en in this
|
||||
# example. The best match wins.
|
||||
return request.accept_languages.best_match(AVAILABLE_LOCALES)
|
||||
return request.accept_languages.best_match(constants.AVAILABLE_LOCALES)
|
||||
|
||||
|
||||
def page_not_found(e):
|
||||
|
|
|
@ -5,8 +5,7 @@ from app.client.client_constants import Commands, ClientStatus
|
|||
|
||||
from app.service.service_entry import ServiceSettings
|
||||
from app.service.stream_handler import IStreamHandler
|
||||
from app.constants import DEFAULT_SERVICE_LOG_PATH_TEMPLATE_3SIS, DEFAULT_STREAM_LOG_PATH_TEMPLATE_3SIS, \
|
||||
DEFAULT_STREAM_PIPELINE_PATH_TEMPLATE_3SIS
|
||||
import app.constants as constants
|
||||
|
||||
|
||||
class ServiceClient(IClientHandler):
|
||||
|
@ -16,15 +15,15 @@ class ServiceClient(IClientHandler):
|
|||
|
||||
@staticmethod
|
||||
def get_log_service_path(host: str, port: int, sid: str):
|
||||
return DEFAULT_SERVICE_LOG_PATH_TEMPLATE_3SIS.format(host, port, sid)
|
||||
return constants.DEFAULT_SERVICE_LOG_PATH_TEMPLATE_3SIS.format(host, port, sid)
|
||||
|
||||
@staticmethod
|
||||
def get_log_stream_path(host: str, port: int, stream_id: str):
|
||||
return DEFAULT_STREAM_LOG_PATH_TEMPLATE_3SIS.format(host, port, stream_id)
|
||||
return constants.DEFAULT_STREAM_LOG_PATH_TEMPLATE_3SIS.format(host, port, stream_id)
|
||||
|
||||
@staticmethod
|
||||
def get_pipeline_stream_path(host: str, port: int, stream_id: str):
|
||||
return DEFAULT_STREAM_PIPELINE_PATH_TEMPLATE_3SIS.format(host, port, stream_id)
|
||||
return constants.DEFAULT_STREAM_PIPELINE_PATH_TEMPLATE_3SIS.format(host, port, stream_id)
|
||||
|
||||
def __init__(self, handler: IStreamHandler, settings: ServiceSettings):
|
||||
self._request_id = 0
|
||||
|
|
|
@ -4,7 +4,7 @@ from flask_classy import FlaskView, route
|
|||
from flask import render_template, request, jsonify
|
||||
from flask_login import login_required, current_user
|
||||
|
||||
from app.constants import StreamType
|
||||
import app.constants as constants
|
||||
from app import get_runtime_stream_folder
|
||||
from app.stream.stream_forms import EncodeStreamForm, RelayStreamForm, TimeshiftRecorderStreamForm, CatchupStreamForm, \
|
||||
TimeshiftPlayerStreamForm, TestLifeStreamForm, VodEncodeStreamForm, VodRelayStreamForm
|
||||
|
@ -228,7 +228,7 @@ class StreamView(FlaskView):
|
|||
stream = server.find_stream_by_id(sid)
|
||||
if stream:
|
||||
type = stream.get_type()
|
||||
if type == StreamType.RELAY:
|
||||
if type == constants.StreamType.RELAY:
|
||||
form = RelayStreamForm(obj=stream)
|
||||
|
||||
if request.method == 'POST' and form.validate_on_submit():
|
||||
|
@ -238,7 +238,7 @@ class StreamView(FlaskView):
|
|||
|
||||
return render_template('stream/relay/edit.html', form=form,
|
||||
feedback_dir=stream.generate_feedback_dir())
|
||||
elif type == StreamType.ENCODE:
|
||||
elif type == constants.StreamType.ENCODE:
|
||||
form = EncodeStreamForm(obj=stream)
|
||||
|
||||
if request.method == 'POST' and form.validate_on_submit():
|
||||
|
@ -248,7 +248,7 @@ class StreamView(FlaskView):
|
|||
|
||||
return render_template('stream/encode/edit.html', form=form,
|
||||
feedback_dir=stream.generate_feedback_dir())
|
||||
elif type == StreamType.TIMESHIFT_RECORDER:
|
||||
elif type == constants.StreamType.TIMESHIFT_RECORDER:
|
||||
form = TimeshiftRecorderStreamForm(obj=stream)
|
||||
|
||||
if request.method == 'POST': # FIXME form.validate_on_submit()
|
||||
|
@ -259,7 +259,7 @@ class StreamView(FlaskView):
|
|||
return render_template('stream/timeshift_recorder/edit.html', form=form,
|
||||
feedback_dir=stream.generate_feedback_dir(),
|
||||
timeshift_dir=stream.generate_timeshift_dir())
|
||||
elif type == StreamType.CATCHUP:
|
||||
elif type == constants.StreamType.CATCHUP:
|
||||
form = CatchupStreamForm(obj=stream)
|
||||
|
||||
if request.method == 'POST': # FIXME form.validate_on_submit()
|
||||
|
@ -270,7 +270,7 @@ class StreamView(FlaskView):
|
|||
return render_template('stream/catchup/edit.html', form=form,
|
||||
feedback_dir=stream.generate_feedback_dir(),
|
||||
timeshift_dir=stream.generate_timeshift_dir())
|
||||
elif type == StreamType.TIMESHIFT_PLAYER:
|
||||
elif type == constants.StreamType.TIMESHIFT_PLAYER:
|
||||
form = TimeshiftPlayerStreamForm(obj=stream)
|
||||
|
||||
if request.method == 'POST' and form.validate_on_submit():
|
||||
|
@ -280,7 +280,7 @@ class StreamView(FlaskView):
|
|||
|
||||
return render_template('stream/timeshift_player/edit.html', form=form,
|
||||
feedback_dir=stream.generate_feedback_dir())
|
||||
elif type == StreamType.TEST_LIFE:
|
||||
elif type == constants.StreamType.TEST_LIFE:
|
||||
form = TestLifeStreamForm(obj=stream)
|
||||
|
||||
if request.method == 'POST': # FIXME form.validate_on_submit()
|
||||
|
@ -290,7 +290,7 @@ class StreamView(FlaskView):
|
|||
|
||||
return render_template('stream/test_life/edit.html', form=form,
|
||||
feedback_dir=stream.generate_feedback_dir())
|
||||
elif type == StreamType.VOD_RELAY:
|
||||
elif type == constants.StreamType.VOD_RELAY:
|
||||
form = VodRelayStreamForm(obj=stream)
|
||||
|
||||
if request.method == 'POST' and form.validate_on_submit():
|
||||
|
@ -300,7 +300,7 @@ class StreamView(FlaskView):
|
|||
|
||||
return render_template('stream/vod_relay/edit.html', form=form,
|
||||
feedback_dir=stream.generate_feedback_dir())
|
||||
elif type == StreamType.VOD_ENCODE:
|
||||
elif type == constants.StreamType.VOD_ENCODE:
|
||||
form = VodEncodeStreamForm(obj=stream)
|
||||
|
||||
if request.method == 'POST' and form.validate_on_submit():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue