Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

cleaned up style

  • Loading branch information...
commit 1cc7cbb9112c01c247d4cf842cd0519d14149d15 1 parent d227f01
Brian Rosner authored January 30, 2013
2  aiteo/models.py
@@ -15,7 +15,6 @@ class Question(models.Model):
15 15
     content = models.TextField()
16 16
     user = models.ForeignKey(User, related_name="questions")
17 17
     created = models.DateTimeField(default=datetime.now)
18  
-    
19 18
     score = models.IntegerField(editable=False, default=0)
20 19
     vote_count = models.IntegerField(editable=False, default=0)
21 20
     
@@ -44,7 +43,6 @@ class Response(models.Model):
44 43
     accepted = models.BooleanField(default=False)
45 44
     user = models.ForeignKey(User, related_name="responses")
46 45
     created = models.DateTimeField(default=datetime.now)
47  
-    
48 46
     score = models.IntegerField(editable=False, default=0)
49 47
     vote_count = models.IntegerField(editable=False, default=0)
50 48
     
21  aiteo/views.py
@@ -14,9 +14,7 @@
14 14
 
15 15
 
16 16
 def question_list(request, **kwargs):
17  
-    
18 17
     questions = Question.objects.all().order_by("-score", "created", "id")
19  
-    
20 18
     ctx = {
21 19
         "questions": questions,
22 20
     }
@@ -25,7 +23,6 @@ def question_list(request, **kwargs):
25 23
 
26 24
 @login_required
27 25
 def question_create(request, **kwargs):
28  
-    
29 26
     if request.method == "POST":
30 27
         form = AskQuestionForm(request.POST)
31 28
         if form.is_valid():
@@ -35,7 +32,6 @@ def question_create(request, **kwargs):
35 32
             return HttpResponseRedirect(question.get_absolute_url())
36 33
     else:
37 34
         form = AskQuestionForm()
38  
-    
39 35
     ctx = {
40 36
         "form": form,
41 37
     }
@@ -43,20 +39,12 @@ def question_create(request, **kwargs):
43 39
 
44 40
 
45 41
 def question_detail(request, question_id, **kwargs):
46  
-    
47 42
     questions = Question.objects.all()
48  
-    
49 43
     question = get_object_or_404(questions, pk=question_id)
50 44
     responses = question.responses.order_by("-score", "created", "id")
51  
-    
52  
-    if question.user == request.user:
53  
-        is_me = True
54  
-    else:
55  
-        is_me = False
56  
-    
  45
+    is_me = question.user == request.user
57 46
     if request.method == "POST":
58 47
         add_response_form = AddResponseForm(request.POST)
59  
-        
60 48
         if add_response_form.is_valid():
61 49
             response = add_response_form.save(commit=False)
62 50
             response.question = question
@@ -68,7 +56,6 @@ def question_detail(request, question_id, **kwargs):
68 56
             add_response_form = AddResponseForm()
69 57
         else:
70 58
             add_response_form = None
71  
-    
72 59
     ctx = {
73 60
         "can_mark_accepted": workflow.can_mark_accepted(request.user, question),
74 61
         "question": question,
@@ -79,18 +66,12 @@ def question_detail(request, question_id, **kwargs):
79 66
 
80 67
 
81 68
 def mark_accepted(request, question_id, response_id, **kwargs):
82  
-    
83 69
     if request.method != "POST":
84 70
         return HttpResponseNotAllowed(["POST"])
85  
-    
86 71
     questions = Question.objects.all()
87  
-    
88 72
     question = get_object_or_404(questions, pk=question_id)
89  
-    
90 73
     if not workflow.can_mark_accepted(request.user, question):
91 74
         return HttpResponseForbidden("You are not allowed to mark this question accepted.")
92  
-    
93 75
     response = question.responses.get(pk=response_id)
94 76
     response.accept()
95  
-    
96 77
     return HttpResponse("good")
1  aiteo/workflow.py
... ...
@@ -1,4 +1,3 @@
1 1
 
2  
-
3 2
 def can_mark_accepted(user, question):
4 3
     return question.user == user

0 notes on commit 1cc7cbb

Please sign in to comment.
Something went wrong with that request. Please try again.