Skip to content
Snippets Groups Projects
Commit 6268e4db authored by kaiyou's avatar kaiyou
Browse files

Move format to the root package

This avoids circular dependencies, as username formats are a general concept
parent bed2e7b1
No related branches found
No related tags found
1 merge request!20Add 'remember me' button
File moved
from hiboo.profile import blueprint, forms, formats
from hiboo import models, utils, security
from hiboo.profile import blueprint, forms
from hiboo import models, utils, security, format
from hiboo import user as hiboo_user
from passlib import context, hash
from flask_babel import lazy_gettext as _
......@@ -25,7 +25,7 @@ def create(service_uuid, create_for=False, quick=False):
service = models.Service.query.get(service_uuid) or flask.abort(404)
status = models.Profile.ACTIVE
is_admin = flask_login.current_user.is_admin
format = formats[service.profile_format]
format = format.ProfileFormat.registry[service.profile_format]
# If the admin passed a user uuid, use that one, otherwise ignore it
user = hiboo_user.get_user(intent="profile.create_for", create_for=None) if (create_for and is_admin) else flask_login.current_user
# Check that profile creation is allowed
......
from wtforms import validators, fields, widgets
from flask_babel import lazy_gettext as _
from hiboo import models, application, profile
from hiboo import models, application, format
import flask_wtf
......@@ -16,8 +16,13 @@ class ServiceForm(flask_wtf.FlaskForm):
[validators.NumberRange(1, 1000)])
profile_format = fields.SelectField(_('Profile username format'),
choices=(
[("", _("Default ({})".format(profile.formats[None].message)))] +
[(name, format.message.capitalize()) for name, format in profile.formats.items() if name]
[("", _("Default ({})".format(
format.ProfileFormat.registry[None].message))
)] +
[(name, format.message.capitalize())
for name, format in format.ProfileFormat.registry.items()
if name is not None
]
)
)
single_profile = fields.BooleanField(_('Enable single-profile behavior (no custom username, no additional profile)'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment