Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Community App Store (Sourcery refactored) #184

Merged
merged 1 commit into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)
Comment on lines -18 to +30
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lock_invite_code refactored with the following changes:

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)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _parse_env_value refactored with the following changes:



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"
Comment on lines -140 to +138
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_database_engine refactored with the following changes:



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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function authenticated refactored with the following changes:



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