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

Feature/flag project #144

Merged
merged 85 commits into from May 21, 2015
Merged

Feature/flag project #144

merged 85 commits into from May 21, 2015

Conversation

dtgay
Copy link
Contributor

@dtgay dtgay commented Apr 16, 2015

This should fix #87, and moooreee! 🌈

  • Adds 'Flag' button to project pages
    • Logged-in users can flag a project with a reason for doing so, such as "please delete this because blah blah blah"
  • Adds an admin view to review, sort, and open/close flags

@@ -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',
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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 :)

return output

@classmethod
def insert(cls, session, user, project, reason):
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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 ;-)

@dtgay
Copy link
Contributor Author

dtgay commented Apr 22, 2015

Alright, things seem to be working! Good to merge?

@pypingou
Copy link
Member

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 :)

@dtgay
Copy link
Contributor Author

dtgay commented May 11, 2015

@pypingou, I've added a good set of tests for both viewing the /flags/ view and attempting to set the flag state under various conditions. All of these tests appear to pass. Let me know what you think!

@dtgay
Copy link
Contributor Author

dtgay commented May 11, 2015

Actually, there is one issue I'm seeing. In test_flag_project, we're getting 405's in these sort of blocks:

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?

@pypingou
Copy link
Member

I see a couple of things here:

@dtgay
Copy link
Contributor Author

dtgay commented May 12, 2015

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 with anitya.app.APP.test_client() as c: blocks, but when I run nosetests, I don't get a failure. 😕

@dtgay
Copy link
Contributor Author

dtgay commented May 19, 2015

I believe this is ready for final review.

@pypingou
Copy link
Member

@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
Copy link
Member

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?

@pypingou
Copy link
Member

Code wise, I have a couple of minor questions but this is looking really good, thanks @oddshocks !!

@dtgay
Copy link
Contributor Author

dtgay commented May 21, 2015

This should be good to finally merge, with final approval.

@pypingou
Copy link
Member

I just tried to run the branch and I got:

  File ".../anitya/anitya/admin.py", line 447, in browse_flags
    total_page = int(ceil(cnt_flags / float(limit)))
UnboundLocalError: local variable 'cnt_flags' referenced before assignment

@pypingou
Copy link
Member

Second one:

  File ".../anitya/anitya/ui.py", line 469, in flag_project
    plugins=plugins,
NameError: global name 'plugins' is not defined

:-)

@pypingou
Copy link
Member

Nice job! 👍 for merging :)

dtgay pushed a commit that referenced this pull request May 21, 2015
@dtgay dtgay merged commit c29d327 into master May 21, 2015
@dtgay dtgay deleted the feature/flag-project branch May 21, 2015 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to propose projects to be deleted
3 participants