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

First pass at content flagging #74

Merged
merged 5 commits into from
Nov 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ help: ## This help.
run: ## Run the development environment from tox.
tox -e devenv

.PHONY: shell
shell: ## Run the django shell using some additional tools.
venv/bin/python manage.py shell_plus

.PHONY: migrate
migrate: makemigrations ## Run migrate on the DB, updating schema per migration files.
venv/bin/python manage.py migrate
Expand Down Expand Up @@ -37,9 +41,10 @@ update-flatpages: venv/bin/django-admin ## Update the flatpages from the markdow
collectstatic: ## Collect static files into the STATIC_ROOT directory.
venv/bin/python manage.py collectstatic

.PHONY: check-deploy
check-deploy: ## Run a check against the project for deployability.
.PHONY: check
check: ## Run various checks against the project
venv/bin/python manage.py check --deploy
venv/bin/python manage.py validate_templates

.PHONY: reestdb
resetdb: ## Remove the development database and regenerate it, loading fixtures.
Expand Down Expand Up @@ -91,14 +96,17 @@ test-travis: ## Test target for travis-ci use.
manage.py test --verbosity=2 $(TEST_SUITE)
coverage report -m --skip-covered

.PHONY: sloccount
sloccount: ## Get sloc count from all Python, html, markdown, Makefile, and shell files.
.PHONY: metadata
metadata: ## Get metadata about the project (sloc, models, urls)
git ls-files \
| grep -v static \
| grep -v manage.py \
| grep -v migrations \
| grep -E '(.py|.html|.md|Makefile|sh)' \
| xargs python sloc.py > sloc.tsv
# This will eventually move to makemigrations, probably, after things aren't in as much flux
venv/bin/python manage.py graph_models -g -a -o models.png
venv/bin/python manage.py show_urls > urls.tsv

.PHONY: clean
clean: ## Remove virtualenv and tox environments, along with compiled/optimized python files.
Expand Down
35 changes: 24 additions & 11 deletions administration/application_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@
@staff_member_required
def list_all_applications(request):
"""View for listing all applications."""
applications = Application.objects.all()
if request.GET.get('all'):
applications = Application.objects.all()
else:
applications = Application.objects.filter(resolution='')
return render(request, 'list_applications.html', {
'title': 'All applications',
'applications': applications,
'tab': 'applications'
'tab': 'applications',
'showing_inactive': request.GET.get('all'),
})


Expand All @@ -42,12 +46,15 @@ def list_all_applications(request):
@staff_member_required
def list_social_applications(request):
"""View for listing only applications for social moderators."""
applications = Application.objects.filter(
application_type__in=Application.SOCIAL_TYPES)
query = Q(application_type__in=Application.SOCIAL_TYPES)
if request.GET.get('all') is None:
query &= Q(resolution='')
applications = Application.objects.filter(query)
return render(request, 'list_applications.html', {
'title': 'My applications',
'applications': applications,
'tab': 'applications'
'tab': 'applications',
'showing_inactive': request.GET.get('all'),
})


Expand All @@ -56,12 +63,15 @@ def list_social_applications(request):
@staff_member_required
def list_content_applications(request):
"""View for only listing applications for content moderators."""
applications = Application.objects.filter(
application_type__in=Application.CONTENT_TYPES)
query = Q(application_type__in=Application.CONTENT_TYPES)
if request.GET.get('all') is None:
query &= Q(resolution='')
applications = Application.objects.filter(query)
return render(request, 'list_applications.html', {
'title': 'My applications',
'applications': applications,
'tab': 'applications'
'tab': 'applications',
'showing_inactive': request.GET.get('all'),
})


Expand Down Expand Up @@ -125,12 +135,15 @@ def view_application(request, application_id=None):
@login_required
def list_participating_applications(request):
"""View for listing applications one is participing in."""
applications = Application.objects.filter(Q(applicant=request.user) |
Q(admin_contact=request.user))
query = (Q(applicant=request.user) | Q(admin_contact=request.user))
if request.GET.get('all') is None:
query &= Q(resolution='')
applications = Application.objects.filter(query)
return render(request, 'list_applications.html', {
'title': 'My applications',
'applications': applications,
'tab': 'applications'
'tab': 'applications',
'showing_inactive': request.GET.get('all'),
})


Expand Down
15 changes: 9 additions & 6 deletions administration/ban_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
)
from django.contrib.auth.models import User
from django.contrib import messages
from django.db.models import Q
from django.shortcuts import (
get_object_or_404,
redirect,
Expand Down Expand Up @@ -42,10 +43,14 @@ def list_bans(request):
@permission_required('administration.can_list_bans', raise_exception=True)
@login_required
def list_participating_bans(request):
bans = Ban.objects.filter(admin_contact=request.user)
query = Q(admin_contact=request.user)
if request.GET.get('all') is None:
query &= Q(active=True)
bans = Ban.objects.filter(query)
return render(request, 'list_bans.html', {
'bans': bans,
'tab': 'bans',
'showing_inactive': request.GET.get('all')
})


Expand All @@ -68,15 +73,13 @@ def create_ban(request):
'title': 'Permission denied',
}, status=403)

try:
flag = Flag.objects.get(pk=request.GET.get('flag'))
except Flag.DoesNotExist:
flag = None
form = BanForm(initial={
'user': user,
'flag': flag,
'end_date': timezone.now(),
'flags': Flag.objects.filter(pk=request.GET.get('flag')),
})
form.fields['flags'].queryset = Flag.objects.filter(
flagged_object_owner=user)
if request.method == 'POST':
form = BanForm(request.POST)
if form.is_valid():
Expand Down
Loading