Permalink
Browse files

style clean-ups

  • Loading branch information...
1 parent c96580d commit bf3d08359b01df7a5c58e209d96ab0ff5d3bf025 @brosner brosner committed Apr 19, 2010
Showing with 40 additions and 32 deletions.
  1. +4 −0 flag/admin.py
  2. +10 −10 flag/models.py
  3. +3 −2 flag/urls.py
  4. +3 −1 flag/views.py
  5. +20 −19 setup.py
View
@@ -1,11 +1,15 @@
from django.contrib import admin
+
from flag.models import FlaggedContent, FlagInstance
+
class InlineFlagInstance(admin.TabularInline):
model = FlagInstance
extra = 0
+
class FlaggedContentAdmin(admin.ModelAdmin):
inlines = [InlineFlagInstance]
+
admin.site.register(FlaggedContent, FlaggedContentAdmin)
View
@@ -2,28 +2,28 @@
from django.db import models
+from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
-from django.contrib.auth.models import User
-
STATUS = (
- ('1', 'flagged'),
- ('2', 'flag rejected by moderator'),
- ('3', 'creator notified'),
- ('4', 'content removed by creator'),
- ('5', 'content removed by moderator'),
+ ("1", "flagged"),
+ ("2", "flag rejected by moderator"),
+ ("3", "creator notified"),
+ ("4", "content removed by creator"),
+ ("5", "content removed by moderator"),
)
+
class FlaggedContent(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
- content_object = generic.GenericForeignKey('content_type', 'object_id')
+ content_object = generic.GenericForeignKey("content_type", "object_id")
creator = models.ForeignKey(User, related_name="flagged_content") # user who created flagged content -- this is kept in model so it outlives content
- status = models.CharField(max_length=1, choices=STATUS, default='1')
+ status = models.CharField(max_length=1, choices=STATUS, default="1")
moderator = models.ForeignKey(User, null=True, related_name="moderated_content") # moderator responsible for last status change
@@ -38,7 +38,7 @@ class FlagInstance(models.Model):
def add_flag(flagger, content_type, object_id, content_creator, comment):
- # check if it's already been flagged
+ # check if it"s already been flagged
try:
flagged_content = FlaggedContent.objects.get(content_type=content_type, object_id=object_id)
except FlaggedContent.DoesNotExist:
View
@@ -1,5 +1,6 @@
from django.conf.urls.defaults import *
-urlpatterns = patterns('',
- url(r'^$', 'flag.views.flag', name="flag"),
+
+urlpatterns = patterns("",
+ url(r"^$", "flag.views.flag", name="flag"),
)
View
@@ -1,10 +1,12 @@
from django.http import HttpResponseRedirect, Http404
+from django.shortcuts import get_object_or_404
+
from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
-from django.shortcuts import get_object_or_404
from flag.models import add_flag
+
@login_required
def flag(request):
View
@@ -1,22 +1,23 @@
from setuptools import setup, find_packages
-
+
+
setup(
- name='django-flag',
- version='0.1.0',
- description='flagging of inapproriate/spam content',
- author='Greg Newman',
- author_email='greg@20seven.org',
- url='http://code.google.com/p/django-flag/',
- packages=find_packages(),
- classifiers=[
- 'Development Status :: 3 - Alpha',
- 'Environment :: Web Environment',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: MIT License',
- 'Operating System :: OS Independent',
- 'Programming Language :: Python',
- 'Framework :: Django',
+ name = "django-flag",
+ version = "0.1.0",
+ description = "flagging of inapproriate/spam content",
+ author = "Greg Newman",
+ author_email = "greg@20seven.org",
+ url = "http://code.google.com/p/django-flag/",
+ packages = find_packages(),
+ classifiers = [
+ "Development Status :: 3 - Alpha",
+ "Environment :: Web Environment",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: MIT License",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python",
+ "Framework :: Django",
],
- include_package_data=True,
- zip_safe=False,
-)
+ include_package_data = True,
+ zip_safe = False,
+)

0 comments on commit bf3d083

Please sign in to comment.