Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
First pass at content flagging
Browse files Browse the repository at this point in the history
  • Loading branch information
Madison Scott-Clary committed Nov 11, 2016
1 parent e92c768 commit cdf58cf
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 58 deletions.
16 changes: 8 additions & 8 deletions administration/flag_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from .models import (
Flag,
)
from activitystream.models import Activity
from usermgmt.models import Notification


Expand Down Expand Up @@ -108,9 +107,9 @@ def view_flag(request, flag_id=None):
content = 'administration.can_view_content_applications'
if request.user not in flag.participants.all() and not \
(not (request.user.has_perm(social) and
flag.flag_type == Flag.SOCIAL) or \
not (request.user.has_perm(content) and
flag.flag_type == Flag.CONTENT)):
flag.flag_type == Flag.SOCIAL) or
not (request.user.has_perm(content) and
flag.flag_type == Flag.CONTENT)):
return render(request, 'permission_denied.html', {
'title': 'Permission denied',
}, status=403)
Expand Down Expand Up @@ -143,14 +142,15 @@ def join_flag(request, flag_id=None):
social = 'administration.can_view_social_applications'
content = 'administration.can_view_content_applications'
if not ((request.user.has_perm(social) and
flag.flag_type == Flag.SOCIAL) or \
flag.flag_type == Flag.SOCIAL) or
(request.user.has_perm(content) and
flag.flag_type == Flag.CONTENT)):
return render(request, 'permission_denied.html', {
'title': 'Permission denied',
}, status=403)
if request.user in flag.participants.all():
message.warning(request, 'You are already a participant in this flag')
messages.warning(request,
'You are already a participant in this flag')
else:
for participant in flag.participants.all():
Notification(
Expand All @@ -159,7 +159,7 @@ def join_flag(request, flag_id=None):
notification_type=Notification.FLAG_PARTICIPANT_JOINED,
subject=flag).save()
flag.participants.add(request.user)
message.success(request, 'You are now a participant in this flag')
messages.success(request, 'You are now a participant in this flag')
return redirect


Expand All @@ -171,7 +171,7 @@ def resolve_flag(request, flag_id=None):
social = 'administration.can_view_social_applications'
content = 'administration.can_view_content_applications'
if not ((request.user.has_perm(social) and
flag.flag_type == Flag.SOCIAL) or \
flag.flag_type == Flag.SOCIAL) or
(request.user.has_perm(content) and
flag.flag_type == Flag.CONTENT)):
return render(request, 'permission_denied.html', {
Expand Down
34 changes: 0 additions & 34 deletions administration/test_flag.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from unittest import skip

from django.test import tag

# from .models import Flag
Expand All @@ -12,224 +10,192 @@ def setUpTestCase(cls):
super(BaseFlagTestCase, cls).setUpTestCase()


@skip("Not implemented")
@tag('as_user')
class TestListAllFlagsViewAsUser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_social_mod')
class TestListAllFlagsViewAsSocialMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_content_mod')
class TestListAllFlagsViewAsContentMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_superuser')
class TestListAllFlagsViewAsSuperuser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_user')
class TestListSocialFlagsViewAsUser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_social_mod')
class TestListSocialFlagsViewAsSocialMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_content_mod')
class TestListSocialFlagsViewAsContentMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_superuser')
class TestListSocialFlagsViewAsSuperuser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_user')
class TestListContentFlagsViewAsUser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_social_mod')
class TestListContentFlagsViewAsSocialMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_content_mod')
class TestListContentFlagsViewAsContentMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_superuser')
class TestListContentFlagsViewAsSuperuser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_user')
class TestCreateFlagViewAsUser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_social_mod')
class TestCreateFlagViewAsSocialMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_content_mod')
class TestCreateFlagViewAsContentMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_superuser')
class TestCreateFlagViewAsSuperuser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_user')
class TestViewFlagViewAsUser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_social_mod')
class TestViewFlagViewAsSocialMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_content_mod')
class TestViewFlagViewAsContentMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_superuser')
class TestViewFlagViewAsSuperuser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_user')
class TestListParticipatingFlagsViewAsUser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_social_mod')
class TestListParticipatingFlagsViewAsSocialMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_content_mod')
class TestListParticipatingFlagsViewAsContentMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_superuser')
class TestListParticipatingFlagsViewAsSuperuser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_user')
class TestClaimFlagViewAsUser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_social_mod')
class TestClaimFlagViewAsSocialMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_content_mod')
class TestClaimFlagViewAsContentMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_superuser')
class TestClaimFlagViewAsSuperuser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_user')
class TestResolveFlagViewAsUser(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_social_mod')
class TestResolveFlagViewAsSocialMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_content_mod')
class TestResolveFlagViewAsContentMod(BaseFlagTestCase):
def test_it_works(self):
self.assertEqual(1+1, 2)


@skip("Not implemented")
@tag('as_superuser')
class TestResolveFlagViewAsSuperuser(BaseFlagTestCase):
def test_it_works(self):
Expand Down
2 changes: 1 addition & 1 deletion administration/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def dashboard(request):
for perm, allowed_type in perms.items():
if request.user.has_perm(perm):
query &= (Q(flag_type=allowed_type) |
Q(participants__in=request.user))
Q(participants__in=[request.user]))

# Non-staff only get their own flags
if not request.user.is_staff:
Expand Down
20 changes: 20 additions & 0 deletions core/templates/coverage-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion honeycomb/revno.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
GIT_REVNO = '73db76c67d3df8486a14f2ed84b5079d92127956'
GIT_REVNO = 'e92c76811e1796f0ff6818a44405ca4335b95129'
VERSION = 'pre-release'
32 changes: 18 additions & 14 deletions sloc.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,32 @@ Count Location
143 activitystream/views.py
0 administration/__init__.py
0 administration/admin.py
181 administration/application_views.py
194 administration/application_views.py
4 administration/apps.py
118 administration/ban_views.py
45 administration/flag_views.py
37 administration/forms.py
177 administration/models.py
123 administration/ban_views.py
183 administration/flag_views.py
46 administration/forms.py
189 administration/models.py
106 administration/templates/admin-tabs-snippet.html
31 administration/templates/create_application.html
37 administration/templates/create_ban.html
23 administration/templates/dashboard.html
40 administration/templates/create_flag.html
24 administration/templates/dashboard.html
54 administration/templates/list-applications-snippet.html
55 administration/templates/list-bans-snippet.html
9 administration/templates/list_applications.html
15 administration/templates/list_bans.html
55 administration/templates/list-flags-snippet.html
16 administration/templates/list_applications.html
16 administration/templates/list_bans.html
16 administration/templates/list_flags.html
76 administration/templates/view_application.html
45 administration/templates/view_ban.html
47 administration/templates/view_flag.html
533 administration/test_application.py
413 administration/test_ban.py
167 administration/test_flag.py
134 administration/test_flag.py
186 administration/tests.py
66 administration/urls.py
36 administration/views.py
52 administration/views.py
0 core/__init__.py
0 core/admin.py
4 core/apps.py
Expand All @@ -57,7 +61,7 @@ Count Location
11 core/templates/flatpages/default.html
18 core/templates/flatpages/list.html
102 core/templates/front.html
9 core/templates/permission_denied.html
14 core/templates/permission_denied.html
65 core/templates/search/search.html
0 core/templatetags/__init__.py
28 core/templatetags/git_revno.py
Expand All @@ -81,7 +85,7 @@ Count Location
11 flatpage-defaults/about-terms.md
16 gen-badge.sh
0 honeycomb/__init__.py
14 honeycomb/middleware.py
17 honeycomb/middleware.py
2 honeycomb/revno.py
148 honeycomb/settings.py
20 honeycomb/urls.py
Expand Down Expand Up @@ -150,7 +154,7 @@ Count Location
37 usermgmt/forms.py
10 usermgmt/group_models.py
119 usermgmt/group_views.py
147 usermgmt/models.py
159 usermgmt/models.py
24 usermgmt/templates/confirm_delete_group.html
20 usermgmt/templates/list_groups.html
107 usermgmt/templates/profile-tabs-snippet.html
Expand Down Expand Up @@ -178,4 +182,4 @@ Count Location
24 usermgmt/urls.py
9 usermgmt/utils.py
87 usermgmt/views.py
11187 TOTAL
11534 TOTAL

0 comments on commit cdf58cf

Please sign in to comment.