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
Feature/flag project #144
Feature/flag project #144
Conversation
@@ -145,7 +145,8 @@ def log(session, project=None, distro=None, topic=None, message=None): | |||
'project: %(project)s', | |||
'project.edit': '%(agent)s edited the project: %(project)s fields: ' | |||
'%(changes)s', | |||
|
|||
'project.flag': '%(agent)s flagged the project: %(project)s', |
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.
Should we include the message in there?
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.
It's your choice. The reason might be kind of long, so I excluded it from the log message, figuring that an admin could check the reason from the Flags view itself. Do you think it'd be good to have it here, as well?
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 think I would like to have it in yes. It'll give the admin an idea what this flag is about when looking at the list of flags.
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.
The admin can already see the reason when looking at the list of flags. The reason is listed there. I just excluded it from this line to avoid a large block of text when viewing the logs. Do you think the full reason should be listed on the Flags and Logs page? If so, I can fix that.
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.
Yes I think it would be useful.
As it is for admins only, we could still easily rework that later on :)
dcf51a8
to
c1a6b83
Compare
return output | ||
|
||
@classmethod | ||
def insert(cls, session, user, project, reason): |
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.
Looks like this is not being used anywhere
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 just added a json representation in case it's used somewhere in fedmsgs or if it would be needed in the future. Should I remove 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.
I meant the insert()
method. It doesn't seem to be used anywhere.
The json representation will be useful for broadcasting fedmsg messages ;-)
Alright, things seem to be working! Good to merge? |
To be entirely feature complete, it needs some unit-tests :-) I also woul like to give it a try locally to see if I missed anything in the review :) |
@pypingou, I've added a good set of tests for both viewing the |
Actually, there is one issue I'm seeing. In with anitya.app.APP.test_client() as c:
with c.session_transaction() as sess:
sess['openid'] = 'http://pingou.id.fedoraproject.org/'
sess['fullname'] = 'Pierre-Yves C.'
sess['nickname'] = 'pingou'
sess['email'] = 'pingou@pingoured.fr'
output = c.get('/flags/{0}/set/closed'.format(flag.id),
follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertEqual(flag.state, 'closed') I'm 99% sure this is because the CSRF protection makes it so you can't directly hit the URL. What do I have to change here to make this call in these tests? |
I see a couple of things here:
|
I took a whack at getting the CSRF token, though I'm not sure I did it right. I thought I'd have to do it for each of those |
d7c2d69
to
146028d
Compare
I believe this is ready for final review. |
@oddshocks github seems to say this PR conflicts with what's in the repo, could you see if you could rebase it? |
|
||
# Don't toggle the state or send a new fedmsg if the flag's | ||
# state wouldn't actually be changed. | ||
if flag.state == state: return |
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.
What about raising an exception here instead?
Code wise, I have a couple of minor questions but this is looking really good, thanks @oddshocks !! |
…e CSRF token from the previous block
a16089e
to
0b50115
Compare
This should be good to finally merge, with final approval. |
I just tried to run the branch and I got:
|
Second one:
:-) |
Nice job! 👍 for merging :) |
This should fix #87, and moooreee! 🌈