Skip to content

Commit

Permalink
minor clean-ups to style
Browse files Browse the repository at this point in the history
  • Loading branch information
brosner committed Jan 12, 2010
1 parent b2999de commit 8538c5f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 18 deletions.
2 changes: 2 additions & 0 deletions aiteo/admin.py
Expand Up @@ -3,6 +3,7 @@
from aiteo.models import Question, Response



class ResponseInline(admin.StackedInline):
model = Response

Expand All @@ -13,4 +14,5 @@ class QuestionAdmin(admin.ModelAdmin):
]



admin.site.register(Question, QuestionAdmin)
2 changes: 1 addition & 1 deletion aiteo/forms.py
Expand Up @@ -3,6 +3,7 @@
from aiteo.models import Question, Response



class AskQuestionForm(forms.ModelForm):

class Meta:
Expand All @@ -15,5 +16,4 @@ class AddResponseForm(forms.ModelForm):
class Meta:
model = Response
fields = ["content"]


3 changes: 2 additions & 1 deletion aiteo/models.py
Expand Up @@ -11,6 +11,7 @@
from voting.models import Vote



class Question(models.Model):

object_id = models.IntegerField(null=True, blank=True)
Expand Down Expand Up @@ -56,7 +57,7 @@ def update_score(self):
self.score = result["score"]
self.vote_count = result["num_votes"]
self.save()

def accept(self):
# check for another active one and mark it inactive
try:
Expand Down
1 change: 1 addition & 0 deletions aiteo/templatetags/extra_voting_tags_mergeme.py
Expand Up @@ -3,6 +3,7 @@
register = template.Library()



@register.filter
def get_state(original_type, vote_obj):
# FIXME: there is a better name for it
Expand Down
22 changes: 13 additions & 9 deletions aiteo/urls.py
@@ -1,32 +1,36 @@
from django.conf.urls.defaults import *

from aiteo.models import Question, Response
from voting.views import vote_on_object

from aiteo.models import Question, Response



urlpatterns = patterns("",
url(r'^$', "aiteo.views.question_list", name="aiteo_question_list"),
url(r'^ask/$', "aiteo.views.question_create", name="aiteo_question_create"),
url(r'^question/(?P<question_id>\d+)/$', "aiteo.views.question_detail", name="aiteo_question_detail"),
url(r'^question/(?P<question_id>\d+)/accept/(?P<response_id>\d+)/$', "aiteo.views.mark_accepted", name="aiteo_mark_accepted"),
url(r"^$", "aiteo.views.question_list", name="aiteo_question_list"),
url(r"^ask/$", "aiteo.views.question_create", name="aiteo_question_create"),
url(r"^question/(?P<question_id>\d+)/$", "aiteo.views.question_detail", name="aiteo_question_detail"),
url(r"^question/(?P<question_id>\d+)/accept/(?P<response_id>\d+)/$", "aiteo.views.mark_accepted", name="aiteo_mark_accepted"),

# Question voting
url(r'^question/vote-question/(?P<object_id>\d+)/(?P<direction>up|down|clear)vote/$',
url(r"^question/vote-question/(?P<object_id>\d+)/(?P<direction>up|down|clear)vote/$",
vote_on_object, dict(
model = Question,
template_object_name = "object",
template_name = "questions/confirm_vote.html",
allow_xmlhttprequest = True
),
name="aiteo_question_vote"),
name="aiteo_question_vote"
),

# Response voting
url(r'^question/vote-response/(?P<object_id>\d+)/(?P<direction>up|down|clear)vote/$',
url(r"^question/vote-response/(?P<object_id>\d+)/(?P<direction>up|down|clear)vote/$",
vote_on_object, dict(
model = Response,
template_object_name = "object",
template_name = "questions/confirm_vote.html",
allow_xmlhttprequest = True
),
name="aiteo_response_vote"),
name="aiteo_response_vote"
),
)
27 changes: 20 additions & 7 deletions aiteo/views.py
Expand Up @@ -8,6 +8,7 @@
from aiteo.models import Question



@login_required # @@@
def question_list(request, group_slug=None, bridge=None):

Expand All @@ -24,10 +25,14 @@ def question_list(request, group_slug=None, bridge=None):
if group:
questions = group.content_objects(questions)

return render_to_response("aiteo/question_list.html", {
ctx = {
"group": group,
"questions": questions,
}, context_instance=RequestContext(request))
}

return render_to_response("aiteo/question_list.html",
context_instance = RequestContext(request, ctx)
)


@login_required
Expand All @@ -51,10 +56,14 @@ def question_create(request, group_slug=None, bridge=None):
else:
form = AskQuestionForm()

return render_to_response("aiteo/question_create.html", {
ctx = {
"group": group,
"form": form,
}, context_instance=RequestContext(request))
}

return render_to_response("aiteo/question_create.html",
context_instance = RequestContext(request)
)


@login_required # @@@
Expand Down Expand Up @@ -83,7 +92,7 @@ def question_detail(request, question_id, group_slug=None, bridge=None):

if request.method == "POST":
add_response_form = AddResponseForm(request.POST)

if add_response_form.is_valid():
response = add_response_form.save(commit=False)
response.question = question
Expand All @@ -96,13 +105,17 @@ def question_detail(request, question_id, group_slug=None, bridge=None):
else:
add_response_form = None

return render_to_response("aiteo/question_detail.html", {
ctx = {
"group": group,
"is_me": is_me,
"question": question,
"responses": responses,
"add_response_form": add_response_form,
}, context_instance=RequestContext(request))
}

return render_to_response("aiteo/question_detail.html",
context_instance = RequestContext(request)
)


@login_required
Expand Down

0 comments on commit 8538c5f

Please sign in to comment.