Modified:
/trunk/pirate-politics/install.sh
/trunk/pirate-politics/new_templates/_voting.html
/trunk/pirate-politics/new_templates/register.html
/trunk/pirate-politics/new_templates/solution_detail.html
/trunk/pirate-politics/new_templates/submit_yea_argument.html
/trunk/pirate-politics/pirate_comments/templatetags/commenttags.py
/trunk/pirate-politics/pirate_consensus/templatetags/consensustags.py
/trunk/pirate-politics/pirate_core/templatetags/tag_helpers.py
/trunk/pirate-politics/pirate_deliberation/templatetags/argumenttags.py
/trunk/pirate-politics/pirate_issues/templatetags/issuetags.py
/trunk/pirate-politics/pirate_issues/templatetags/usertags.py
=======================================
--- /trunk/pirate-politics/install.sh Mon Jan 17 12:55:26 2011
+++ /trunk/pirate-politics/install.sh Thu Feb 10 14:21:57 2011
@@ -20,7 +20,6 @@
cd lib
# grab all of the dependencies
- git clone git://gitorious.org/python-markdown/mainline.git
python-markdown
hg clone http://bitbucket.org/legutierr/djangoappengine/
hg clone http://bitbucket.org/legutierr/django-nonrel/
hg clone http://bitbucket.org/legutierr/djangotoolbox/
@@ -29,6 +28,9 @@
hg clone http://bitbucket.org/offline/django-annoying/
hg clone http://bitbucket.org/jespern/django-piston/
hg clone http://bitbucket.org/jmoiron/django-selector/
+ hg clone http://bitbucket.org/fragro/markdown
+ hg clone http://bitbucket.org/fragro/beautifulsoup
+
# go back to where you started
cd $HERE
@@ -43,6 +45,8 @@
ln -s ../../lib/django-piston/piston
ln -s ../../lib/django-selector/dselector.py
ln -s ../../lib/python-markdown/markdown
+ ln -s ../../markdown/python-markdown/markdown
+ ln -s ../../beautifulsoup/BeautifulSoup.py
# add the app.yaml file
cp app.yaml.example app.yaml
=======================================
--- /trunk/pirate-politics/new_templates/_voting.html Sun Feb 6 23:05:17
2011
+++ /trunk/pirate-politics/new_templates/_voting.html Thu Feb 10 14:21:57
2011
@@ -10,11 +10,11 @@
<img src= "{{pp_consensus.downvoteimg}}"
id="downvoteimg{{request.object.id}}"
onclick="downvote({{request.object.id}},'downcount{{request.object.id}}', 'downvoteimg{{request.object.id}}','');"
/>
{% else %}
- <img src= "{{pp_consensus.upvoteimg}}"
id="upvoteimg{{request.object.id}}" onclick="js_redirect('welcome.html');"/>
+ <img src= "{{pp_consensus.upvoteimg}}"
id="upvoteimg{{request.object.id}}"
onclick="js_redirect('register.html?_r={{request.META.PATH_INFO}}?{{request.META.QUERY_STRING}}');"/>
- <img src= "{{pp_consensus.neutvoteimg}}"
id="neutvoteimg{{request.object.id}}"
onclick="js_redirect('welcome.html');" />
-
- <img src= "{{pp_consensus.downvoteimg}}"
id="downvoteimg{{request.object.id}}"
onclick="js_redirect('welcome.html');" />
+ <img src= "{{pp_consensus.neutvoteimg}}"
id="neutvoteimg{{request.object.id}}"
onclick="js_redirect('register.html?_r={{request.META.PATH_INFO}}?{{request.META.QUERY_STRING}}');"
/>
+
+ <img src= "{{pp_consensus.downvoteimg}}"
id="downvoteimg{{request.object.id}}"
onclick="js_redirect('register.html?_r={{request.META.PATH_INFO}}?{{request.META.QUERY_STRING}}');"
/>
{% endif %}
</div>
=======================================
--- /trunk/pirate-politics/new_templates/register.html Wed Feb 9 00:35:14
2011
+++ /trunk/pirate-politics/new_templates/register.html Thu Feb 10 14:21:57
2011
@@ -17,7 +17,7 @@
{% block content%}
-{% pp_user_registration_form returnurl=request.returnurl request=request %}
+
<div class="register_title">
<h2>Welcome to OpenAssembly: Alpha</h2>
</div>
@@ -28,6 +28,7 @@
<div class="register_registration">
<h3> Register a new account!</h3>
<form method="post" action="">
+{% pp_user_registration_form returnurl=request.returnurl request=request %}
Username:<br>
{{ pp_login.form.name }}<br>
Password:<br>
@@ -41,6 +42,7 @@
<input type="submit" class="button green" value="Register">
<div class="error">{{pp_login.errors}}<br>{{ pp_login.form.errors
}}</div>
</form>
+{% endpp_user_registration_form %}
</div>
<div class="register_login">
<h3> Login to existing account!</h3>
@@ -59,7 +61,7 @@
</div>
-{% endpp_user_registration_form %}
+
{% endblock content %}
=======================================
--- /trunk/pirate-politics/new_templates/solution_detail.html Tue Feb 8
19:28:28 2011
+++ /trunk/pirate-politics/new_templates/solution_detail.html Thu Feb 10
14:21:57 2011
@@ -51,10 +51,7 @@
{% endifequal %}
{% endifequal %}
{% endifequal %}</div>
-
-{% endpp_comment_count %}
-
-
+ {% endpp_comment_count %}
</div>
@@ -66,7 +63,7 @@
{{pp_solution.solution.text|markdown }}
{% endautoescape %}
</div>
- {% include "_sourcetags.html" %}
+ {% include "_sourcetags.html" %}
=======================================
--- /trunk/pirate-politics/new_templates/submit_yea_argument.html Wed Feb
9 00:35:14 2011
+++ /trunk/pirate-politics/new_templates/submit_yea_argument.html Thu Feb
10 14:21:57 2011
@@ -12,7 +12,7 @@
<div class="issuemask">
<div class="submissionbound">
<h2>Submit a new Yea argument for:
<fragrobr>{{request.object.name}}</h2>
-{% pp_argument_form POST=request.POST path=request.path
object=request.object request=request arg_type='yea' %}
+{% pp_argument_form POST=request.POST object=request.object
request=request arg_type='yea' %}
<div class="add">
<div class="errors">{{ pp_argumentation.form.errors }}</div>
<form method="post" action="">
=======================================
--- /trunk/pirate-politics/pirate_comments/templatetags/commenttags.py Fri
Jan 28 02:56:45 2011
+++ /trunk/pirate-politics/pirate_comments/templatetags/commenttags.py Thu
Feb 10 14:21:57 2011
@@ -148,7 +148,7 @@
This block tag can create or process forms either to create or to
modify issues.
Usage is as follows:
- {% pp_comment_form POST=request.POST path=request.path
object=request.object user=request.user %}
+ {% pp_comment_form POST=request.POST object=request.object
user=request.user %}
Do stuff with {{ pp-comment.form }}.
{% endpp_comment_form %}
'''
@@ -157,7 +157,6 @@
namespace = get_namespace(context)
POST = kwargs.get('POST', None)
- path = kwargs.get('path', None)
reply_to = kwargs.get('object',None)
user = kwargs.get('user', None)
comment = kwargs.get('edit',None)
=======================================
--- /trunk/pirate-politics/pirate_consensus/templatetags/consensustags.py
Sun Feb 6 23:05:17 2011
+++ /trunk/pirate-politics/pirate_consensus/templatetags/consensustags.py
Thu Feb 10 14:21:57 2011
@@ -31,7 +31,8 @@
"be assigned the string value 'consensus.")
user = kwargs.pop('user', None)
- namespace['consensus'] = Consensus.objects.get(object_pk=object_pk)
+ try: namespace['consensus'] =
Consensus.objects.get(object_pk=object_pk)
+ except: raise ValueError("pp_consensus_get tag requires that the
object reference by 'object_pk' argument be referenced by an existing
consensus object.")
namespace['upvotes'] = UpDownVote.objects.filter(vote_type=1,parent=
namespace['consensus']).count()
namespace['downvotes'] =
UpDownVote.objects.filter(vote_type=-1,parent=
namespace['consensus']).count()
namespace['neutvotes'] = UpDownVote.objects.filter(vote_type=0,parent=
namespace['consensus']).count()
@@ -62,11 +63,11 @@
namespace['downvoteimg'] = "/static/voteimgs/down_arrow_" +
typedown + ".png"
namespace['hasdownvoted'] = v == -1
else:
- namespace['smallupvoteimg'] = "/static/voteimgs/up_arrow_" +
typeup + "_small.png"
+ namespace['upvoteimg'] = "/static/voteimgs/up_arrow_" + typeup
+ "_small.png"
namespace['hasupvoted'] = v == 1
- namespace['smallneutvoteimg'] = "/static/voteimgs/neut_arrow_" +
typeneut + "_small.png"
+ namespace['neutvoteimg'] = "/static/voteimgs/neut_arrow_" +
typeneut + "_small.png"
namespace['hasneutvoted'] = v == 0
- namespace['smalldownvoteimg'] = "/static/voteimgs/down_arrow_" +
typedown + "_small.png"
+ namespace['downvoteimg'] = "/static/voteimgs/down_arrow_" +
typedown + "_small.png"
namespace['hasdownvoted'] = v == -1
output = nodelist.render(context)
=======================================
--- /trunk/pirate-politics/pirate_core/templatetags/tag_helpers.py Tue Feb
8 19:28:28 2011
+++ /trunk/pirate-politics/pirate_core/templatetags/tag_helpers.py Thu Feb
10 14:21:57 2011
@@ -203,9 +203,9 @@
obj = kwargs.get('object',None)
POST = kwargs.get('POST',None)
- path = kwargs.get('path',None)
tag = kwargs.get('tag',None)
-
+ user = kwargs.get('user',None)
+
if POST and POST.get("form_id") == "pp_tag_form":
if tag != None:
Tag.objects.add_tag(obj, tag.name)
=======================================
--- /trunk/pirate-politics/pirate_deliberation/templatetags/argumenttags.py
Tue Feb 8 19:28:28 2011
+++ /trunk/pirate-politics/pirate_deliberation/templatetags/argumenttags.py
Thu Feb 10 14:21:57 2011
@@ -56,30 +56,34 @@
context.push()
namespace = get_namespace(context)
- solution = kwargs.pop('object', None)
+ obj = kwargs.pop('object', None)
arg_type = kwargs.pop('arg_type', None)
- rng = kwargs.pop('rng', None)
+ start = kwargs.pop('start',None)
+ end = kwargs.pop('end',None)
+
arg_list = Argument.objects.all()
if isinstance(arg_type, unicode):
arg_type, created = Stance.objects.get_or_create(arg=arg_type)
- if isinstance(rng, basestring):
+ if isinstance(start, int) and isinstance(end, int):
try:
- rng = rng.strip("()").split(",")
- rng = (int(rng[0]), int(rng[1]))
+ rng = (int(start), int(end))
except:
rng = None
+
if not rng or len(rng) != 2:
- raise ValueError("The argument 'rng='"+ str(rng) + " to the
pp_argument_list tag must be "
- "provided either in the form of an (int, int)
pair, or "
- "as a string in the form of '(<int>,
<int>)'.")
- if solution and isinstance(solution, Solution):
- arg_list =
arg_list.filter(parent__id=solution.id).order_by('-pub_date')
+ 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 obj:
+ arg_list = arg_list.filter(parent__id=obj.id).order_by('-pub_date')
if arg_type:
arg_list = arg_list.filter(arg_type__id=arg_type.id)
if rng:
- arg_list = arg_list[rng[0]:rng[1]]
+ arg_list = arg_list[start:end]
if arg_list == None:
arg_list = []
@@ -102,11 +106,10 @@
context.push()
namespace = get_namespace(context)
- POST = kwargs.get('POST', None)
- path = kwargs.get('path', "")
+ POST = kwargs.get('POST',None)
obj = kwargs.get('object', None)
arg_type = kwargs.get('arg_type', None)
- request = kwargs.get('request',None)
+ user = kwargs.get('user',None)
if isinstance(arg_type, unicode):
arg_type, created = Stance.objects.get_or_create(arg=arg_type)
@@ -121,11 +124,11 @@
if POST and POST.get("form_id") == "pp_argument_form":
form = ArgumentForm(POST) if arg is None else ArgumentForm(POST,
instance=arg)
- if form.is_valid():
+ if form.is_valid() and user.is_authenticated():
new_arg = form.save(commit=False)
new_arg.pub_date = datetime.datetime.now()
new_arg.parent = solution
- new_arg.user = request.user
+ new_arg.user = user
new_arg.text = clean_html(new_arg.text)
new_arg.name = clean_html(new_arg.name)
new_arg.arg_type = arg_type
=======================================
--- /trunk/pirate-politics/pirate_issues/templatetags/issuetags.py Wed Feb
9 00:35:14 2011
+++ /trunk/pirate-politics/pirate_issues/templatetags/issuetags.py Thu Feb
10 14:21:57 2011
@@ -175,27 +175,12 @@
if not rng or len(rng) != 2:
raise ValueError("The argument 'start=' and 'end=' to the
pp_get_issue_list tag must be "
"provided either in the form of an int")
- else: rng = None
-
- #TODO: future functionality to get user-specific lists
- #however, it may be better to put this in the discovery module, to
avoid cyclic dependency
- #if user:
- # issue_list = pp_discovery.facade.issue_list_for_user(user,
topic=topic, rng=rng)
- #else:
-
-
- #initial issue/consensus lists
- #issue_list = Issue.objects.all()
- ###TODO:THIS QUERY IS NOT SUPPORTED AS IT REQUIRES A JOIN
- ###THIS METHOD IS INEFFICIENT, WILL NOT SCALE PAST A FEW HUNDRED DB
ENTRIES
- #consensus_list = Consensus.objects.filter(content_type__name =
u'issue')
+ else:
+ rng = (0,20)
consensus_list = Consensus.objects.all()
issue_list = Issue.objects.all()
- adjust_for_range = True
- if not rng: #need to add a range if not specified.
- rng = (0,20)
if topic and isinstance(topic, Topic): #filter by topic
issue_list = issue_list.filter(topic__id=topic.id)
@@ -227,8 +212,7 @@
try: namespace['count'] = issue_list.count()
except: namespace['count'] = 0
- if adjust_for_range: #filter for rng
- issue_list = issue_list[rng[0]:rng[1]]
+ issue_list = issue_list[rng[0]:rng[1]]
namespace['issue_list'] = issue_list
@@ -256,7 +240,7 @@
POST = kwargs.get('POST', None)
path = kwargs.get('path', None)
obj = kwargs.get('object',None)
- request = kwargs.get('request',None)
+ user = kwargs.get('user',None)
#question: issue_consensus doesn't seem to be used. Is there a future
need for it?
#issue_consensus = kwargs.get('consensus', None)
@@ -287,9 +271,9 @@
form = TopicIssueForm(POST)
- if form.is_valid():
+ if form.is_valid() and user.is_authenticated():
issue = form.save(commit=False)
- issue.user = request.user
+ issue.user = user
if not isinstance(obj, Issue):
issue.solutions = 0
issue.arguments = 0
=======================================
--- /trunk/pirate-politics/pirate_issues/templatetags/usertags.py Tue Jan
25 15:15:31 2011
+++ /trunk/pirate-politics/pirate_issues/templatetags/usertags.py Thu Feb
10 14:21:57 2011
@@ -32,20 +32,33 @@
@block
def pp_user_registration_form(context, nodelist, *args, **kwargs):
- '''form_id = forms.CharField(widget=forms.HiddenInput(),
initial="pp-issue-form")
+ '''form_id = forms.CharField(widget=forms.HiddenInput(),
initial="pp_user_registration_form")
This block tag can create or process forms either to create or to
modify issues.
Usage is as follows:
- {% pp_issue_form POST=request.POST path=request.path
issue=pp_issue.issue topic=request.object %}
- Do stuff with {{ pp-issue.form }}.
- {% endpp-issue-form %}
+ {% pp_user_registration_form request=request
return_path=request.MATH.PATH_INFO return_query=request.META.QUERY_STRING %}
+ Do stuff with {{ pp_login.form }}.
+ {% endpp_user_login_form%}
'''
context.push()
namespace = get_namespace(context)
- POST = kwargs.get('POST', None)
- path = kwargs.get('path', "")
- request = kwargs.get('request',None)
+ request = kwargs.get('request')
+ return_path= kwargs.get('return_path')
+ return_query= kwargs.get('return_query')
+ returnurl = kwargs.get('returnurl') #this is for register.html
+
+ if request is not None:
+ POST = request.POST
+ else:
+ raise ValueError("Tag pp_user_login_form must contain the
argument 'request=request'")
+
+ if return_path is not None and return_query is not None:
+ returnurl = return_path + '?' + return_query
+ elif returnurl is not None:
+ returnurl = returnurl.replace('%','&')
+ else:
+ returnurl = '/issues.html?_s=0&_e=20&_d=hot'
if POST and POST.get("form_id") == "pp_user_registration_form":
try:
@@ -63,7 +76,7 @@
if user is not None:
if user.is_active:
login(request, user)
- raise
HttpRedirectException(HttpResponseRedirect("/issues.html"))
+ raise
HttpRedirectException(HttpResponseRedirect(returnurl))
else:
namespace['errors'] = "Passwords are not the same. Try
again."
@@ -96,41 +109,51 @@
@block
def pp_user_login_form(context, nodelist, *args, **kwargs):
- '''form_id = forms.CharField(widget=forms.HiddenInput(),
initial="pp-issue-form")
+ '''form_id = forms.CharField(widget=forms.HiddenInput(),
initial="pp_user_login_form")
This block tag can create or process forms either to create or to
modify issues.
Usage is as follows:
- {% pp_issue_form POST=request.POST path=request.path
issue=pp_issue.issue topic=request.object %}
- Do stuff with {{ pp-issue.form }}.
- {% endpp-issue-form %}
+ {% pp_user_login_form request=request
return_path=request.MATH.PATH_INFO return_query=request.META.QUERY_STRING %}
+ Do stuff with {{ pp_login.form }}.
+ {% endpp_user_login_form%}
'''
context.push()
namespace = get_namespace(context)
- POST = kwargs.get('POST', None)
- path = kwargs.get('path', "")
- request = kwargs.get('request',None)
- obj = kwargs.get('object', None)
+ request = kwargs.get('request')
+ return_path= kwargs.get('return_path')
+ return_query= kwargs.get('return_query')
+ returnurl = kwargs.get('returnurl') #this is for register.html
+
+ if request is not None:
+ POST = request.POST
+ else:
+ raise ValueError("Tag pp_user_login_form must contain the
argument 'request=request'")
+ if return_path is not None and return_query is not None:
+ returnurl = return_path + '?' + return_query
+ elif returnurl is not None:
+ returnurl = returnurl.replace('%','&')
+ elif return_path is not None and return_query is None:
+ returnurl = return_path
+ else:
+ returnurl = '/issues.html?_s=0&_e=20&_d=hot'
if POST and POST.get("form_id") == "pp_user_login_form":
try:
- form = LoginForm(POST)
- new_user = form.save()
- user = authenticate(username=new_user.name,
password=new_user.password)
- if user is not None:
- if user.is_active:
- login(request, user)
- if obj:
- content_type = ContentType.objects.get_for_model(obj)
- temp = template_for_model(str(content_type))
- path2 = temp + "?_t=" + str(content_type.pk) + "&_o=" +
str(obj.pk)
- if path != temp: path2 = path + "?_t=" +
str(content_type.pk) + "&_o=" + str(obj.pk)
- else: path2 = temp + "?_t=" + str(content_type.pk)
+ "&_o=" + str(obj.pk)
-
- raise HttpRedirectException(HttpResponseRedirect(path2))
-
- else:
- raise
HttpRedirectException(HttpResponseRedirect('/issues.html'))
+ form = LoginForm(POST)
+ if form.is_valid():
+ new_user = form.save()
+ user = authenticate(username=new_user.name,
password=new_user.password)
+ if user is not None:
+ if user.is_active:
+ login(request, user)
+ else: #TODO: form is erroneous somehow, need to find out
how and add to error text
+ pass
+
+ raise
HttpRedirectException(HttpResponseRedirect(returnurl))
+ else: #TODO: form is empty in some way, add this message to
error
+ pass
+
except HttpRedirectException, e:
raise e
else:
@@ -143,6 +166,7 @@
return output
+
class LoginForm(forms.ModelForm):
def save(self, commit=True):
@@ -150,6 +174,7 @@
return new_user
class Meta:
- model = Login
+ model = Login
form_id = forms.CharField(widget=forms.HiddenInput(),
initial="pp_user_login_form")
- password =
forms.CharField(label=_(u'Password'),widget=forms.PasswordInput(render_value=False))
+ name = forms.CharField(label=_(u'Name'))
+ password =
forms.CharField(label=_(u'Pass'),widget=forms.PasswordInput(render_value=False))