-
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
Conversation
fas_group, group.name) | ||
else: | ||
message = "Group {} is activated in the System under the alias {} ".format( | ||
fas_group, alias) |
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.
:-) how do you trigger this one actually? Is there a reproducer?
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.
:-) how do you trigger this one actually? Is there a reproducer?
Yeah, i just go /groups/activate/<group_name>
twice with two different alias
The second submit will lead to a 404 page
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.
AAAh, this. Yeah, I totally misunderstood the thing you want to fix (I though you want to map 2 external groups to a single Copr group, and it is vice versa).
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.
Could you please return "400 Bad Request" if user visits /groups/activate/<existing_group>
for the second time? There's no such link, so that must be an error anyway (processing the request seems just redundant).
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.
Will simplely return 400 be a good experience?
Or just redirect user to the existed group
?
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.
Not sure. Do you think users can get to the route once it is activated? If yes, redirecting is indeed a better option.
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.
Not sure. Do you think users can get to the route once it is activated? If yes, redirecting is indeed a better option.
Seems no possible unless they know the route and play with it like me :)
But return 400 or redirect will not waste anything, so why not?
@@ -37,7 +37,7 @@ <h1> | |||
<tbody> | |||
{% for team in teams %} | |||
<tr> | |||
<td><a href="{{ fas_group_href(team) }}"> | |||
<td><a href="{{ config.GROUP_INFO.link.format(name=team) }}"> |
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.
Is this #2563?
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 with GROUP_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?
Nit that I can fix myself for the PR - but would be helpful to write commit messages like:
|
82339c8
to
fe562e2
Compare
I tried to describe it in the newly pushed commit message, any advice appreciated 😃 |
This was a correct action (adding the index via migration); can you add the migration script into this PR? |
fe562e2
to
744e2d3
Compare
Ah i forget to push this file 🐷, Done |
frontend/coprs_frontend/alembic/versions/daa62cd0743d_add_unique_constraint_to_fas_group.py
Fixed
Show fixed
Hide fixed
744e2d3
to
5647ba1
Compare
# can't have more than one alias for a group | ||
if group.name != alias: | ||
message = "Group {} already activated as alias {} ".format( | ||
fas_group, group.name) |
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.
If we go with error 400 or redirect, this if/else
condition is redundant. While on this, would you mind making the flash message "green" with flash("message", "success")
:-) so it is more visible? The grey color doesn't look like something actually happened...
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.
Done
5647ba1
to
20546b8
Compare
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 comment
The 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 comment
The 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 comment
The 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(...)
Done
+1 (note the missing thing above, but still good enough) |
b1d1f4d
to
931e2a9
Compare
db.session.add(group) | ||
group = UsersLogic.create_group_by_fas_name(fas_group, alias) | ||
# db.session.add(group) is done by UsersLogic.create_group_by_fas_name() | ||
db.session.flush() |
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.
I bet flush()
is not needed. I'd drop the commented-out line with db.session.add()
(NB adding the same object twice shouldn't hurt).
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.
You are right, commit()
will unconditionally call flush()
before commit
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.
I bet
flush()
is not needed. I'd drop the commented-out line withdb.session.add()
(NB adding the same object twice shouldn't hurt).
But why should we still keep add()
since it was done by create_group_by_fas_name
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, add()
is redundant, I have no objections to removing it.
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,
add()
is redundant, I have no objections to removing it.
I totally misunderstand you :)
Done
When i was developing group supported in OIDC, i found some wired hehavior in group activated in fedora-copr#2825, So i submitted this PR, and @praiskup also give advice a TODO so i include the fix as well This PR try to fix: fedora-copr#2825 1. add unique contraint to fas_name and add migration script generated by alembic revision --autogenerate 2. I think macro fas_group_href canbe replaced by config.GROUP_INFO.link.forma which is more configurable 3. When creating a new alias for a group, if the group already has one alias, popup a flash and redirect to the already existed group Signed-off-by: Li Chaoran <[email protected]>
931e2a9
to
2ea10ff
Compare
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.
thank you
NOTE: Needs manual merge. |
Merged as: bddee02 Thank you. |
This PR try to fix: #2825 also fortunately fix: #2563
fas_name
and add migration script generated byalembic revision --autogenerate
fas_group_href
canbe replaced byonfig.GROUP_INFO.link.forma
which is more configurable