Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed group functionality

  • Loading branch information...
commit abe89df70f2c2695440839ebb8428b4e23bc7745 1 parent 1a89064
@brosner brosner authored
Showing with 7 additions and 78 deletions.
  1. +0 −28 aiteo/groups.py
  2. +1 −14 aiteo/models.py
  3. +6 −36 aiteo/views.py
View
28 aiteo/groups.py
@@ -1,28 +0,0 @@
-from django.core.exceptions import ObjectDoesNotExist
-from django.http import Http404
-
-
-def group_and_bridge(kwargs):
- """
- Given kwargs from the view (with view specific keys popped) pull out the
- bridge and fetch group from database.
- """
-
- bridge = kwargs.pop("bridge", None)
-
- if bridge:
- try:
- group = bridge.get_group(**kwargs)
- except ObjectDoesNotExist:
- raise Http404
- else:
- group = None
-
- return group, bridge
-
-
-def group_context(group, bridge):
- # @@@ use bridge
- return {
- "group": group,
- }
View
15 aiteo/models.py
@@ -5,18 +5,12 @@
from django.db.models.signals import post_save
from django.contrib.auth.models import User
-from django.contrib.contenttypes import generic
-from django.contrib.contenttypes.models import ContentType
from voting.models import Vote
class Question(models.Model):
- group_content_type = models.ForeignKey(ContentType, null=True, blank=True)
- group_object_id = models.IntegerField(null=True, blank=True)
- group = generic.GenericForeignKey("group_content_type", "group_object_id")
-
question = models.CharField(max_length=100)
content = models.TextField()
user = models.ForeignKey(User, related_name="questions")
@@ -40,14 +34,7 @@ def accepted_response(self):
return response
def get_absolute_url(self):
- kwargs = {
- "question_id": self.pk,
- }
- if self.group:
- reverse_func = self.group.content_bridge.reverse
- else:
- reverse_func = reverse
- return reverse_func("aiteo_question_detail", kwargs=kwargs)
+ return reverse("aiteo_question_detail", kwargs=dict(question_id=self.pk))
class Response(models.Model):
View
42 aiteo/views.py
@@ -8,7 +8,6 @@
from django.contrib.auth.decorators import login_required
from aiteo.forms import AskQuestionForm, AddResponseForm
-from aiteo.groups import group_and_bridge, group_context
from aiteo.models import Question
@@ -17,20 +16,11 @@
def question_list(request, **kwargs):
- group, bridge = group_and_bridge(kwargs)
-
questions = Question.objects.all().order_by("-score", "created", "id")
- if group:
- questions = group.content_objects(questions)
- else:
- questions = questions.filter(group_content_type=None)
-
- ctx = group_context(group, bridge)
- ctx.update({
- "group": group,
+ ctx = {
"questions": questions,
- })
+ }
ctx = RequestContext(request, ctx)
return render_to_response("aiteo/question_list.html", ctx)
@@ -39,8 +29,6 @@ def question_list(request, **kwargs):
@login_required
def question_create(request, **kwargs):
- group, bridge = group_and_bridge(kwargs)
-
if request.method == "POST":
form = AskQuestionForm(request.POST)
if form.is_valid():
@@ -51,11 +39,9 @@ def question_create(request, **kwargs):
else:
form = AskQuestionForm()
- ctx = group_context(group, bridge)
- ctx.update({
- "group": group,
+ ctx = {
"form": form,
- })
+ }
ctx = RequestContext(request, ctx)
return render_to_response("aiteo/question_create.html", ctx)
@@ -63,15 +49,8 @@ def question_create(request, **kwargs):
def question_detail(request, question_id, **kwargs):
- group, bridge = group_and_bridge(kwargs)
-
questions = Question.objects.all()
- if group:
- questions = group.content_objects(questions)
- else:
- questions = questions.filter(group_content_type=None)
-
question = get_object_or_404(questions, pk=question_id)
responses = question.responses.order_by("-score", "created", "id")
@@ -95,14 +74,12 @@ def question_detail(request, question_id, **kwargs):
else:
add_response_form = None
- ctx = group_context(group, bridge)
- ctx.update({
- "group": group,
+ ctx = {
"can_mark_accepted": workflow.can_mark_accepted(request.user, question),
"question": question,
"responses": responses,
"add_response_form": add_response_form,
- })
+ }
ctx = RequestContext(request, ctx)
return render_to_response("aiteo/question_detail.html", ctx)
@@ -113,15 +90,8 @@ def mark_accepted(request, question_id, response_id, **kwargs):
if request.method != "POST":
return HttpResponseNotAllowed(["POST"])
- group, bridge = group_and_bridge(kwargs)
-
questions = Question.objects.all()
- if group:
- questions = group.content_objects(questions)
- else:
- questions = questions.filter(group_content_type=None)
-
question = get_object_or_404(questions, pk=question_id)
if not workflow.can_mark_accepted(request.user, question):
Please sign in to comment.
Something went wrong with that request. Please try again.