def tagproplist(request, tag_slug): tag = get_object_or_404(Tag, slug=tag_slug) proposals = tag.proposals.order_by('create_date')[:]#for debugging purposes, results should actually be paginated taglist = Tag.all_objects_sorted_by_num_proposals() return render(request, 'proposal/list.html', { 'latest_proposal_list': proposals, 'taglist': taglist, 'title': "Latest proposals on %s" % tag.name.lower() })
def setUp(self): numusers = 20 self.users = [] for i in xrange(numusers): u = CustomUser(username=u"U%d" % i) u.save() self.users.append(u) numtags = 10 self.tags = [] for i in xrange(numtags): t = Tag(name=u"T%d" % i) t.save() self.tags.append(t) tupples = [ (0, [], [1, 2, 3, 4], True), (1, [], [2, 3, 4], True), (2, [], [1, 3, 4], True), (3, [], [5, 6], True), (4, [], [7, 8], True), (5, [], [9], True), (7, [], [10], True), ] self.proxies = [] for tupple in tupples: p = Proxy(delegating=self.users[tupple[0]], isdefault=tupple[3]) p.save() for t in tupple[1]: p.tags.add(self.tags[t]) for d in tupple[2]: p.delegates.add(self.users[d]) p.save() self.proxies.append(p) doc = FullDocument() doc.save() diff = Diff(fulldocument=doc) diff.save() self.proposal = AmendmentProposal(title="Test", diff=diff, motivation="Motivation") self.proposal.save()
def setUp(self): numusers = 20 self.users = [] for i in xrange(numusers): u = CustomUser(username=u"U%d"%i) u.save() self.users.append(u) numtags = 10 self.tags = [] for i in xrange(numtags): t = Tag(name=u"T%d"%i) t.save() self.tags.append(t) tupples = [ (0, [], [1, 2, 3, 4], True), (1, [], [2, 3, 4], True), (2, [], [1, 3, 4], True), (3, [], [5, 6], True), (4, [], [7, 8], True), (5, [], [9], True), (7, [], [10], True), ] self.proxies = [] for tupple in tupples: p = Proxy(delegating = self.users[tupple[0]], isdefault=tupple[3]) p.save() for t in tupple[1]: p.tags.add(self.tags[t]) for d in tupple[2]: p.delegates.add(self.users[d]) p.save() self.proxies.append(p) doc = FullDocument() doc.save() diff = Diff(fulldocument=doc) diff.save() self.proposal = AmendmentProposal(title="Test", diff=diff, motivation="Motivation") self.proposal.save()
def tagproplist(request, tag_slug): tag = get_object_or_404(Tag, slug=tag_slug) proposals = tag.proposals.order_by( 'create_date' )[:] #for debugging purposes, results should actually be paginated taglist = Tag.all_objects_sorted_by_num_proposals() return render( request, 'proposal/list.html', { 'latest_proposal_list': proposals, 'taglist': taglist, 'title': "Latest proposals on %s" % tag.name.lower() })
def proplist(request, list_type="latest"): # TODO: pagination if list_type == "following": if not request.user.is_authenticated(): path = request.build_absolute_uri() return redirect_to_login(path) proposals = request.user.favorites.order_by('-create_date') timeline = TimelineData( filterkeywords=["created", "voting_starts"], proposal_generators=(proposals, proposals), right_grey=True, ) elif list_type == "latest": proposals = Proposal.objects.order_by('-create_date') # timeline = TimelineData( # filterkeywords = ["created", "voting_starts"], # proposal_generators = (proposals, proposals), # right_grey = True, # ) timeline = None elif list_type == "voting": proposals = Proposal.objects.filter( voting_stage='VOTING').order_by('-voting_date') timeline = TimelineData( filterkeywords=["voting_started", "voting_ends"], proposal_generators=(proposals, proposals), left_grey=True, ) elif list_type == "all": proposals = Proposal.objects.order_by('-create_date') timeline = TimelineData( filterkeywords=["created", ""], proposal_generators=(proposals, proposals), right_grey=True, ) taglist = Tag.all_objects_sorted_by_num_proposals() return render( request, 'proposal/list.html', { 'latest_proposal_list': proposals, 'taglist': taglist, 'timeline': timeline, })
def proplist(request, list_type="latest"): # TODO: pagination if list_type == "following": if not request.user.is_authenticated(): path = request.build_absolute_uri() return redirect_to_login(path) proposals = request.user.favorites.order_by('-create_date') timeline = TimelineData( filterkeywords = ["created", "voting_starts"], proposal_generators = (proposals, proposals), right_grey = True, ) elif list_type == "latest": proposals = Proposal.objects.order_by('-create_date') # timeline = TimelineData( # filterkeywords = ["created", "voting_starts"], # proposal_generators = (proposals, proposals), # right_grey = True, # ) timeline = None elif list_type == "voting": proposals = Proposal.objects.filter(voting_stage='VOTING').order_by('-voting_date') timeline = TimelineData( filterkeywords = ["voting_started", "voting_ends"], proposal_generators = (proposals, proposals), left_grey = True, ) elif list_type == "all": proposals = Proposal.objects.order_by('-create_date') timeline = TimelineData( filterkeywords = ["created", ""], proposal_generators = (proposals, proposals), right_grey = True, ) taglist = Tag.all_objects_sorted_by_num_proposals() return render(request, 'proposal/list.html', { 'latest_proposal_list': proposals, 'taglist': taglist, 'timeline': timeline, })