Commit c1596b5b authored by Daniel W Bond's avatar Daniel W Bond

broke out moderation into a separate app

parent e2435e72
from django.contrib import admin
# Register your models here.
from django.db import models
# Create your models here.
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare • Mod
{% endblock title %}
{% block content %}
<div class="row">
<div class="col-md-10 col-md-offset-1 text-center">
<h1>Listings by number of Flags</h1>
</div>
</div>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<table class="table table-bordered table-hover table-condensed text-center">
<thead>
<td class="col-md-1"><h4><strong>Number</strong></h4></td>
<td class="col-md-6"><h4><strong>Title</strong></h4></td>
<td class="col-md-3"><h4><strong>Poster</strong></h4></td>
<td class="col-md-2"><h4><strong>Action</strong></h4></td>
</thead>
<tbody>
{% for listing in listings %}
<tr>
<td>{{ listing.num_flags }}</td>
<td><a href="{{ listing.get_absolute_url }}" target="_blank">
<strong>{{ listing.title }}</strong>
</a></td>
<td><a href="{{ listing.poster.get_absolute_url }}" target="_blank">
{{ listing.poster.user.get_full_name }}
</a></td>
<td><a href="{% url 'delete_listing' listing.slug %}">
<span class="label label-danger"><strong>Delete</strong></span>
</a></td>
</tr>
{% empty %}
Nothing Here!
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock content %}
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare &bull; Mod
{% endblock title %}
{% block content %}
<div class="row">
<div class="col-md-10 col-md-offset-1 text-center">
<h1>Listings by number of Flags</h1>
</div>
</div>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<table class="table table-bordered table-hover table-condensed text-center">
<thead>
<td class="col-md-1"><h4><strong>Number</strong></h4></td>
<td class="col-md-6"><h4><strong>Title</strong></h4></td>
<td class="col-md-3"><h4><strong>Poster</strong></h4></td>
<td class="col-md-2"><h4><strong>Action</strong></h4></td>
</thead>
<tbody>
{% for listing in listings %}
<tr>
<td>{{ listing.num_flags }}</td>
<td><a href="{{ listing.get_absolute_url }}" target="_blank">
<strong>{{ listing.title }}</strong>
</a></td>
<td><a href="{{ listing.poster.get_absolute_url }}" target="_blank">
{{ listing.poster.user.get_full_name }}
</a></td>
<td><a href="{% url 'delete_listing' listing.slug %}">
<span class="label label-danger"><strong>Delete</strong></span>
</a></td>
</tr>
{% empty %}
Nothing Here!
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock content %}
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare &bull; Mod
{% endblock title %}
{% block content %}
<div class="row">
<div class="col-md-10 col-md-offset-1 text-center">
<h1>Listings by number of Flags</h1>
</div>
</div>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<table class="table table-bordered table-hover table-condensed text-center">
<thead>
<td class="col-md-1"><h4><strong>Number</strong></h4></td>
<td class="col-md-6"><h4><strong>Title</strong></h4></td>
<td class="col-md-3"><h4><strong>Poster</strong></h4></td>
<td class="col-md-2"><h4><strong>Action</strong></h4></td>
</thead>
<tbody>
{% for listing in listings %}
<tr>
<td>{{ listing.num_flags }}</td>
<td><a href="{{ listing.get_absolute_url }}" target="_blank">
<strong>{{ listing.title }}</strong>
</a></td>
<td><a href="{{ listing.poster.get_absolute_url }}" target="_blank">
{{ listing.poster.user.get_full_name }}
</a></td>
<td><a href="{% url 'delete_listing' listing.slug %}">
<span class="label label-danger"><strong>Delete</strong></span>
</a></td>
</tr>
{% empty %}
Nothing Here!
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock content %}
from django.test import TestCase
# Create your tests here.
# core django imports
from django.conf.urls import patterns, url
from django.views.decorators.cache import cache_page
# imports from your apps
from .views import ModLandingView, FlagModView, ListingNumModView,\
UserEmailRatioModView
urlpatterns = patterns('',
url(r'^$', cache_page(60 * 15)(ModLandingView.as_view()), name='mod_page'),
url(r'^flags/$', FlagModView.as_view(), name='flag_mod'),
url(r'^listing-nums/$', ListingNumModView.as_view(), name='listing_nums'),
url(r'^email-ratio/$', UserEmailRatioModView.as_view(), name='email_ratio'),
)
# core django imports
from django.views.generic import TemplateView, ListView
from django.db.models import Sum
# third party imports
from braces.views import LoginRequiredMixin, SuperuserRequiredMixin
# imports from your apps
from trades.models import Listing
class ModLandingView(LoginRequiredMixin, SuperuserRequiredMixin, TemplateView):
template_name = 'mod.html'
class FlagModView(LoginRequiredMixin, SuperuserRequiredMixin, ListView):
queryset = Listing.objects.annotate(num_flags=Count('flag')).order_by('-num_flags')[:20]
context_object_name = 'listings'
template_name = 'flag_mod.html'
login_url = 'login'
class ListingNumModView(LoginRequiredMixin, SuperuserRequiredMixin, ListView):
queryset = Listing.objects.all()[:20]
context_object_name = 'users'
template_name = 'listing_num_mod.html'
login_url = 'login'
class UserEmailRatioModView(LoginRequiredMixin, SuperuserRequiredMixin, TemplateView):
template_name = 'email_ratio_mod.html'
def get_context_data(self, **kwargs):
context = super(UserEmailRatioView, self).get_context_data(**kwargs)
return context
......@@ -37,6 +37,7 @@ INSTALLED_APPS = (
'trades',
'core',
'lookouts',
'mod',
# packages
'randomslugfield',
'django_gravatar',
......
......@@ -6,7 +6,7 @@ from django.conf import settings
from django.contrib import admin
from django.views.decorators.cache import cache_page
# imports from your apps
from .views import HomepageView, ChartsView, ModView
from .views import HomepageView, ChartsView
admin.autodiscover()
......@@ -20,6 +20,7 @@ urlpatterns = patterns('',
url(r'^share/', include('trades.urls')),
url(r'^student/', include('core.urls')),
url(r'^lookouts/', include('lookouts.urls')),
url(r'^mod/', include('mod.urls')),
# search
url(r'^search/', include('haystack.urls'), name='search'),
......@@ -30,8 +31,6 @@ urlpatterns = patterns('',
url(r'^$', HomepageView.as_view(), name='homepage'),
url(r'^charts/?$', cache_page(60 * 10)(ChartsView.as_view()), name='charts'),
url(r'^mod/?$', ModView.as_view(), name='mod'),
# static pages
url(r'^about/?$',
cache_page(60 * 15)(TemplateView.as_view(template_name='about.html')),
......
# standard library imports
from collections import Counter
# core django imports
from django.views.generic import TemplateView, ListView
from django.views.generic import TemplateView
from django.db.models import Sum, Count
# third party imports
from braces.views import LoginRequiredMixin, SuperuserRequiredMixin
from braces.views import LoginRequiredMixin
# imports from your apps
from lookouts.models import Lookout
from trades.models import Listing, Bid
......@@ -55,9 +55,3 @@ class ChartsView(LoginRequiredMixin, TemplateView):
context['total_students'] = Student.objects.count()
context['total_proceeds'] = total_proceeds
return context
class ModView(LoginRequiredMixin, SuperuserRequiredMixin, ListView):
queryset = Listing.objects.annotate(num_flags=Count('flag')).order_by('-num_flags')[:20]
context_object_name = 'listings'
template_name = 'mod.html'
login_url = 'login'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment