Пример #1
0
    def testCurrentIssue(self):
        self.assertEqual(Issue.current_issue(), self.issue_2)
        self.issue_2.published = False
        self.issue_2.save()

        self.assertEqual(Issue.current_issue(), self.issue_1)

        self.issue_2.published = True
        self.issue_2.save()
Пример #2
0
def new_issue_view(request):
    if request.method == "POST":
        form = IssueForm(request.POST)
        if form.is_valid():
            new_issue = Issue(title=form.cleaned_data["title"])
            new_issue.save()
            new_issue_contributor = Issue_Contributor(issue=new_issue, contributor=request.user)
            new_issue_contributor.save()
            return HttpResponseRedirect("/dashboard/")
    else:
        form = IssueForm()
    context = {}
    context.update(csrf(request))
    context["form"] = form
    return render(request, "dashboard/new_issue_view.html", context)
Пример #3
0
def new_issue_view(request):
    if request.method == 'POST':
        form = IssueForm(request.POST)
        if form.is_valid():
            new_issue = Issue(title=form.cleaned_data['title'])
            new_issue.save()
            new_issue_contributor = Issue_Contributor(issue=new_issue,
                                                      contributor=request.user)
            new_issue_contributor.save()
            return HttpResponseRedirect('/dashboard/')
    else:
        form = IssueForm()
    context = {}
    context.update(csrf(request))
    context['form'] = form
    return render(request, 'dashboard/new_issue_view.html', context)
Пример #4
0
def index(request):
    latest_issue = Issue.current_issue()
    articles = Article.objects.filter(issue=latest_issue)

    context = {'latest_issue': latest_issue, 'articles': articles}

    return render (request, 'magazine/index.html', context)
Пример #5
0
    def get_current_issue(self):
        if not hasattr(self, 'current_issue'):
            self.current_issue = Issue.current_issue()

        return self.current_issue
Пример #6
0
 def testLiveIssues(self):
     self.assertEqual(Issue.current_issue(), None)