This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Implement project (Team) closing #4287
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e33a69e
Failing test for team (project) closing
chadwhitacre 08627ab
Add Python API for closing teams
chadwhitacre 20ec01e
Harmonize "Close" styles across pages
chadwhitacre d453ecd
Add UI for closing a project
chadwhitacre c7fa2b1
Don't show closed teams on the homepage
chadwhitacre de2aa54
Trim whitespace
chadwhitacre 03b264f
Add projects notice to participant close page
chadwhitacre 73926df
Bring participant close tests up to date
chadwhitacre 6b191f0
Hide closed teams from ~user profile
mattbk 36948c0
Beef up implementation of closed filtering
chadwhitacre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from .available import AvailableMixin as Available | ||
from .closing import ClosingMixin as Closing | ||
from .membership import MembershipMixin as Membership | ||
from .takes import TakesMixin as Takes | ||
from .tip_migration import TipMigrationMixin as TipMigration | ||
|
||
__all__ = ['Available', 'Membership', 'Takes', 'TipMigration'] | ||
__all__ = ['Available', 'Closing', 'Membership', 'Takes', 'TipMigration'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
from gratipay.models import add_event | ||
|
||
|
||
class ClosingMixin(object): | ||
"""This mixin implements team closing. | ||
""" | ||
|
||
#: Whether the team is closed or not. | ||
|
||
is_closed = False | ||
|
||
|
||
def close(self): | ||
"""Close the team account. | ||
""" | ||
with self.db.get_cursor() as cursor: | ||
cursor.run("UPDATE teams SET is_closed=true WHERE id=%s", (self.id,)) | ||
add_event(cursor, 'team', dict(id=self.id, action='set', values=dict(is_closed=True))) | ||
self.set_attributes(is_closed=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.danger-zone { | ||
margin-top: 64px; | ||
border: 1px solid $red; | ||
@include border-radius(5px); | ||
padding: 20px; | ||
h2 { | ||
margin: 0 0 10px; | ||
padding: 0; | ||
color: $red; | ||
} | ||
button { | ||
background: $red; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
from gratipay.testing import Harness, T | ||
|
||
|
||
class TestTeamClosing(Harness): | ||
|
||
def test_teams_can_be_closed_via_python(self): | ||
team = self.make_team() | ||
team.close() | ||
assert team.is_closed | ||
|
||
def test_teams_can_be_closed_via_http(self): | ||
self.make_team() | ||
response = self.client.PxST('/TheEnterprise/edit/close', auth_as='picard') | ||
assert response.headers['Location'] == '/~picard/' | ||
assert response.code == 302 | ||
assert T('TheEnterprise').is_closed | ||
|
||
def test_but_not_by_anon(self): | ||
self.make_team() | ||
response = self.client.PxST('/TheEnterprise/edit/close') | ||
assert response.code == 401 | ||
|
||
def test_nor_by_turkey(self): | ||
self.make_participant('turkey') | ||
self.make_team() | ||
response = self.client.PxST('/TheEnterprise/edit/close', auth_as='turkey') | ||
assert response.code == 403 | ||
|
||
def test_admin_is_cool_though(self): | ||
self.make_participant('Q', is_admin=True) | ||
self.make_team() | ||
response = self.client.PxST('/TheEnterprise/edit/close', auth_as='Q') | ||
assert response.headers['Location'] == '/~Q/' | ||
assert response.code == 302 | ||
assert T('TheEnterprise').is_closed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from aspen import Response | ||
from gratipay.utils import get_team | ||
|
||
[----------------------------------------------------------------------------] | ||
|
||
if user.ANON: | ||
raise Response(401, _("You need to log in to access this page.")) | ||
|
||
request.allow('POST') | ||
|
||
team = get_team(state) | ||
|
||
if not user.ADMIN and user.participant.username != team.owner: | ||
raise Response(403, _("You are not authorized to access this page.")) | ||
|
||
if team.is_closed: | ||
raise Response(403, _("Already closed.")) | ||
|
||
team.close() | ||
|
||
website.redirect('/~{}/'.format(user.participant.username)) | ||
[---] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 about disable "close" button instead?
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 this was quicker to put together. We can enhance (add project reopening?) once the basic functionality is 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.
Sounds good. BTW after your latest commit (hide closed team), in theory user should not reach here, as they won't see the already closed 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.
If you try to close again by URL for some reason, you would get this error. All my latest commit did was hide the link to the project from the project owner's profile.