Пример #1
0
def create(request):
    sunetid = request.session['webauth_sunetid']
    attrs = request.POST.copy()
    new_issue = Issue(kind=attrs['kind'], sunetid1=sunetid).get_typed()
    form = form_class_for_issue(new_issue)(attrs, instance=new_issue)
    if form.is_valid() and new_issue.can_declare():
        form.save()
        return HttpResponseRedirect(reverse('openelections.issues.views.manage_index'))
    else:
        return render_to_response('issues/manage/new.html', {'new_issue': new_issue, 'form': form}, context_instance=RequestContext(request))
Пример #2
0
def create(request):
    sunetid = request.user.webauth_username
    attrs = request.POST.copy()
    if len(attrs) == 0 or 'kind' not in attrs:
        return HttpResponseNotFound("The form did not submit correctly. Please try again.")
    new_issue = Issue(kind=attrs['kind'], sunetid1=sunetid).get_typed()
    form = form_class_for_issue(new_issue)(attrs, instance=new_issue)
    if form.is_valid() and new_issue.can_declare():
        form.save()
        return HttpResponseRedirect(reverse('openelections.issues.views.manage_index'))
    else:
        return render_to_response('issues/manage/new.html', {'new_issue': new_issue, 'form': form,'error': True}, context_instance=RequestContext(request))
Пример #3
0
def create(request):
    sunetid = request.session['webauth_sunetid']
    attrs = request.POST.copy()
    new_issue = Issue(kind=attrs['kind'], sunetid1=sunetid).get_typed()
    form = form_class_for_issue(new_issue)(attrs, instance=new_issue)
    if form.is_valid() and new_issue.can_declare():
        form.save()
        return HttpResponseRedirect(
            reverse('openelections.issues.views.manage_index'))
    else:
        return render_to_response('issues/manage/new.html', {
            'new_issue': new_issue,
            'form': form
        },
                                  context_instance=RequestContext(request))
Пример #4
0
def manage_new(request, issue_kind):
    sunetid = request.session['webauth_sunetid']
    new_issue = Issue(kind=issue_kind, sunetid1=sunetid).get_typed()
    form = form_class_for_issue(new_issue)(instance=new_issue)
    return render_to_response('issues/manage/new.html', {
        'new_issue': new_issue,
        'form': form
    },
                              context_instance=RequestContext(request))
Пример #5
0
def index(request, show=None):
    return HttpResponseRedirect('http://ballot.stanford.edu/ballot/')
    issues = None
    if show:
        kind_filter = index_filters.get(show, None)
        if kind_filter is None:
            return HttpResponseNotFound()
        issues = Issue.filter_by_kinds(kind_filter).filter(public=True).all()
    else:
        issues = Issue.objects.filter(public=True).all()
    issues = map(Issue.get_typed, issues)
    random.shuffle(issues)
    return render_to_response('issues/index.html', {'issues': issues, 'detail': False}, context_instance=RequestContext(request))
Пример #6
0
def index(request, show=None):
    return HttpResponseRedirect('http://ballot.stanford.edu/ballot/')
    issues = None
    if show:
        kind_filter = index_filters.get(show, None)
        if kind_filter is None:
            return HttpResponseNotFound()
        issues = Issue.filter_by_kinds(kind_filter).filter(public=True).all()
    else:
        issues = Issue.objects.filter(public=True).all()
    issues = map(Issue.get_typed, issues)
    random.shuffle(issues)
    return render_to_response('issues/index.html', {
        'issues': issues,
        'detail': False
    },
                              context_instance=RequestContext(request))
Пример #7
0
def index(request, show=None):
    issues = None
    if show:
        kind_filter = index_filters.get(show, None)
        if kind_filter is None:
            return HttpResponseNotFound()
        issues = Issue.filter_by_kinds(kind_filter).filter(public=True).all()
    else:
        return render_to_response('issues/welcome.html', context_instance=RequestContext(request))

    issues = map(Issue.get_typed, issues)
    random.shuffle(issues)

    if show == 'grad':
        newissues = list()
        for i in issues:
            if i.kind == oe_constants.ISSUE_SPECFEE and i.is_grad_issue() == False:
                continue
            newissues.append(i)
        issues = newissues

    return render_to_response('issues/index.html', {'issues': issues, 'detail': False}, context_instance=RequestContext(request))
Пример #8
0
def manage_index(request):
    sunetid = request.session['webauth_sunetid']
    issues = map(Issue.get_typed, Issue.filter_by_sponsor(sunetid))
    return render_to_response('issues/manage/index.html', {'issues': issues}, context_instance=RequestContext(request))
Пример #9
0
def manage_index(request):
    sunetid = request.session['webauth_sunetid']
    issues = map(Issue.get_typed, Issue.filter_by_sponsor(sunetid))
    return render_to_response('issues/manage/index.html', {'issues': issues},
                              context_instance=RequestContext(request))
Пример #10
0
 def test_filter_by_kinds(self):
     senators = Issue.filter_by_kinds(['US']).all()
     lsenator = senators[0].get_typed()
     self.assertEquals(issue('leland-senator'), lsenator)
     execs = Issue.filter_by_kinds(['Exec']).all()
     self.assertEquals(len(execs), 3)