Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Aug 1, 2022
1 parent 136ac50 commit 410dfee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
16 changes: 11 additions & 5 deletions conreq/_core/sign_up/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ def _lock_invite_code(_event):
code.save()
set_locked(True)

if not locked:
return html.button(
return (
None
if locked
else html.button(
{"className": "btn btn-sm", "onClick": _lock_invite_code},
html.span({"className": "glyphicon glyphicon-lock", "aria-hidden": "true"}),
html.span(
{
"className": "glyphicon glyphicon-lock",
"aria-hidden": "true",
}
),
)

return None
)
9 changes: 2 additions & 7 deletions conreq/utils/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def _parse_env_value(value: Any, default_value: Any, return_type: Callable) -> A
return default_value
if return_type in {list, dict} and isinstance(value, str):
return json.loads(value)
if not isinstance(value, return_type):
return return_type(value)
return value
return value if isinstance(value, return_type) else return_type(value)


def get_env(
Expand Down Expand Up @@ -137,10 +135,7 @@ def get_database_engine() -> str:
if _DB_ENGINE is None:
_DB_ENGINE = get_env("DB_ENGINE", "").upper()

if _DB_ENGINE in {"MYSQL"}:
return _DB_ENGINE

return "SQLITE3"
return _DB_ENGINE if _DB_ENGINE in {"MYSQL"} else "SQLITE3"


def set_env(name: str, value: Any, sys_env=False, dot_env=True) -> Tuple[str, str]:
Expand Down
4 changes: 1 addition & 3 deletions conreq/utils/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ def staff_required(view, login_url=None, redirect_field_name=None):
def authenticated(view, auth_level: str = AuthLevel.user):
if auth_level == AuthLevel.user:
return login_required(view)
if auth_level == AuthLevel.admin:
return staff_required(view)
return view
return staff_required(view) if auth_level == AuthLevel.admin else view


def stub(request, *args, **kwargs):
Expand Down

0 comments on commit 410dfee

Please sign in to comment.