from django.db import models
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from tagging.models import Tag
from django.utils.translation import ugettext as _
from pirate_forum.models import ForumBlob
#Stance is a type of argument -- probably specified by admin
[docs]class Stance(models.Model):
arg = models.CharField(max_length=20)
def __unicode__(self):
return self.arg
#An argument of {arg_type} that is attached to an Issue
#This should be a oa-wikipage instance
[docs]class Argument(ForumBlob):
stance = models.ForeignKey(Stance)
class Meta:
verbose_name = _('argument')
#help_text = _('Supply an Argument for your position.')
def __unicode__(self):
return self.summary
[docs] def get_verbose_name(self):
return self._meta.verbose_name
[docs] def get_blob_key(self):
return 'arg'
[docs] def taggable(self):
return True
from django import forms
from django.forms.extras import SelectDateWidget
from pirate_deliberation.models import Argument, Stance
from pirate_topics.models import Topic
from pirate_forum.forms import BlobForm
from pirate_core.forms import FormMixin
from pirate_core.widgets import HorizRadioRenderer
from django.contrib.contenttypes.models import ContentType
import datetime
from markitup.widgets import MarkItUpWidget
[docs]def get_argument_list(parent, start, end, dimension, ctype_list):
arg_list = Argument.objects.all()
arg_type, created = Stance.objects.get_or_create(arg=dimension)
if isinstance(start, int) and isinstance(end, int):
try:
rng = (int(start), int(end))
except:
rng = None
if not rng or len(rng) != 2:
raise ValueError("The argument 'start=' and 'end=' to the pp_get_argument_list tag must be "
"provided either in the form of an int")
else:
rng = (0, 20)
if parent:
arg_list = arg_list.filter(parent_pk=parent.id).order_by('-created_dt')
if arg_type:
arg_list = arg_list.filter(stance=arg_type)
#get total number of arguments
count = arg_list.count()
if rng:
arg_list = arg_list[start:end]
if arg_list == None:
arg_list = []
return arg_list, count