-
Notifications
You must be signed in to change notification settings - Fork 58
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
group alias need 1:1 mapping to group #2826
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
add unique constraint to fas_group | ||
|
||
Revision ID: daa62cd0743d | ||
Revises: ba6ac0936bfb | ||
Create Date: 2023-08-01 09:52:01.522171 | ||
""" | ||
|
||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'daa62cd0743d' | ||
down_revision = 'ba6ac0936bfb' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_unique_constraint(None, 'group', ['fas_name']) | ||
|
||
|
||
def downgrade(): | ||
op.drop_constraint(None, 'group', type_='unique') |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
from coprs.logic.coprs_logic import CoprsLogic, PinnedCoprsLogic | ||
from coprs.logic.users_logic import UsersLogic | ||
from coprs import app | ||
from coprs.oidc import oidc_enabled | ||
|
||
from ... import db | ||
from ..misc import login_required | ||
|
@@ -21,6 +22,15 @@ | |
@groups_ns.route("/activate/<fas_group>", methods=["GET", "POST"]) | ||
@login_required | ||
def activate_group(fas_group): | ||
msg_fmt = "Group {} is activated in the system under the alias {}" | ||
|
||
group = UsersLogic.get_group_by_fas_name(fas_group).first() | ||
if group: | ||
# can't have more than one alias for a group | ||
flask.flash(msg_fmt.format(group.fas_name, group.name), "success") | ||
return flask.redirect(url_for( | ||
"groups_ns.list_projects_by_group", group_name=group.name)) | ||
|
||
form = ActivateFasGroupForm() | ||
|
||
if form.validate_on_submit(): | ||
|
@@ -31,22 +41,17 @@ def activate_group(fas_group): | |
|
||
if fas_group not in flask.g.user.user_teams: | ||
raise InsufficientRightsException( | ||
"User '{}' doesn't have access to fas group {}" | ||
"User '{}' doesn't have access to group {}" | ||
.format(flask.g.user.username, fas_group)) | ||
|
||
alias = form.name.data | ||
group = UsersLogic.get_group_by_fas_name_or_create( | ||
fas_group, alias) | ||
group = UsersLogic.create_group_by_fas_name(fas_group, alias) | ||
|
||
db.session.add(group) | ||
db.session.commit() | ||
|
||
flask.flash( | ||
"FAS group {} is activated in the Copr under the alias {} " | ||
.format(fas_group, alias) | ||
) | ||
flask.flash(msg_fmt.format(group.fas_name, group.name), "success") | ||
return flask.redirect(url_for( | ||
"groups_ns.list_projects_by_group", group_name=alias)) | ||
"groups_ns.list_projects_by_group", group_name=group.name)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is certainly OK and better behavior than before, thank you! What I thought meant before was that we should redirect the user (or error 400) much earlier, before the user starts even thinking about how to name the group (it is wasting of time, the group is already activated so nothing will happen). Something like: def activate_group(fas_group):
if "fas group is activated":
return flask.redirect(...) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's sounds a good idea, will tweak the code :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done |
||
|
||
else: | ||
return flask.render_template( | ||
|
@@ -85,7 +90,7 @@ def list_projects_by_group(group_name, page=1): | |
@groups_ns.route("/list/my") | ||
@login_required | ||
def list_user_groups(): | ||
if not (app.config['FAS_LOGIN'] or app.config['LDAP_URL']): | ||
if not (app.config['FAS_LOGIN'] or app.config['LDAP_URL'] or oidc_enabled(app.config)): | ||
raise ObjectNotFound("Fedora Accounts or LDAP groups not enabled") | ||
|
||
teams = flask.g.user.user_teams | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this #2563?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don‘t know this ticket before :) but in our case, we should be redirect to openEuler group info page instead of
fas_group
stuff, so i think fas_group_href can be replaced withGROUP_INFO.link
😄There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that's exactly #2563 (forgotten hard-coded link). Can you use
Fixes: #2563
, too?