Example #1
0
def opportunities(request):
    from models import OPPORTUNITY_SUB_TYPES
    context = RequestContext(request)    
    sub_types = OPPORTUNITY_SUB_TYPES
    auto_checks=[]
    sub_types_grouped = list(split_by(sub_types, 4))
    now = datetime.datetime.now()

    if request.GET:
        #check to see if there are multiple filter values or one single filter value
        if len(request.GET) > 1 or request.GET.get("page") == None and not request.GET.get("refresh"): 
            filtered_objects = []
            filtered_append = filtered_objects.append
            for get in request.GET:
                if get != "page":
                    get_objects = Opportunity.objects \
                        .filter(subtype = get) \
                        .filter(status = 1) \
                        .filter(deadline__gte = now) \
                        .order_by("deadline")
                    for object in get_objects:
                        filtered_append(object)
                    auto_checks.append(get)
                                                       
            sorted_objects = sorted(filtered_objects,key=attrgetter('deadline'))   
            opportunities_count = len(sorted_objects)
            opportunites_paginator = RhizomePaginator(sorted_objects, per_page=20, url=request.get_full_path())

        else:
            opportunites = Opportunity.objects \
                .filter(status=1) \
                .filter(deadline__gte = now) \
                .order_by("deadline") 
            opportunities_count = len(opportunites)
            opportunites_paginator = RhizomePaginator(opportunites, per_page=20, url=request.get_full_path())
                   
    else:
        opportunites = Opportunity.objects \
            .filter(status=1) \
            .filter(deadline__gte = now) \
            .order_by("deadline") 
        opportunities_count = len(opportunites)
        opportunites_paginator = RhizomePaginator(opportunites, per_page=20, url=request.get_full_path())
  
    opportunites_paginator.set_current_page(request.GET.get("page"))
        
    d = {
         "include_section_header": True,
         "section_title": "Rhizome Opportunities",
         "section_action": "submit",     
         "announce_paginator":opportunites_paginator,
         "include_section_header":True,
         "opportunities_count":opportunities_count,
         "auto_checks":auto_checks,
         "sub_types_grouped":sub_types_grouped,
         }
    
    return render_to_response("announce/opportunities.html",d,context)
Example #2
0
    def filter_proposals(self, request):
        '''
        allows the staff to filter proposals for judges
        '''
        context_instance = RequestContext(request)
        opts = self.model._meta
        admin_site = self.admin_site

        current_proposals = Proposal.objects.current()
        current_proposals_count = len(current_proposals)

        divisor = current_proposals_count / 2

        split_proposals = list(split_by(current_proposals, divisor))

        paginator = Paginator(current_proposals, 1)

        # Make sure page request is an int. If not, deliver first page.
        try:
            page = int(request.GET.get('page', '1'))
        except ValueError:
            page = 1

        # If page request (9999) is out of range, deliver last page of results.
        try:
            awaiting_approval = paginator.page(page)
        except (EmptyPage, InvalidPage):
            print request.path
            return HttpResponseRedirect("%s" % request.path)

        if request.method == "POST":
            finalist = request.POST.get("finalist")
            proposal_id = request.POST.get("id")
            proposal = Proposal.objects.get(pk=proposal_id)

            if finalist == "on":
                proposal.finalist = 1
            else:
                proposal.finalist = 0
            proposal.save()

            return HttpResponseRedirect("%s" % request.build_absolute_uri())

        d = {
            'admin_site': admin_site.name,
            'title': "Filter proposals for Judges",
            'opts': "Proposals",
            'app_label': opts.app_label,
            'awaiting_approval': awaiting_approval
        }

        return render_to_response(
            'admin/commissions/proposals/filter_proposals.html', d,
            context_instance)
Example #3
0
    def filter_proposals(self, request):
        '''
        allows the staff to filter proposals for judges
        '''
        context_instance = RequestContext(request)
        opts = self.model._meta
        admin_site = self.admin_site 

        current_proposals = Proposal.objects.current()
        current_proposals_count = len(current_proposals)

        divisor = current_proposals_count / 2
        
        split_proposals =  list(split_by(current_proposals, divisor))
                
        paginator = Paginator(current_proposals, 1)
        
        # Make sure page request is an int. If not, deliver first page.
        try:
            page = int(request.GET.get('page', '1'))
        except ValueError:
            page = 1

        # If page request (9999) is out of range, deliver last page of results.
        try:
            awaiting_approval = paginator.page(page)
        except (EmptyPage, InvalidPage):
            print request.path
            return HttpResponseRedirect("%s" % request.path)
            
        if request.method == "POST":
            finalist = request.POST.get("finalist")
            proposal_id  = request.POST.get("id")   
            proposal = Proposal.objects.get(pk = proposal_id)

            if finalist == "on":
                proposal.finalist = 1
            else:
                proposal.finalist = 0                
            proposal.save()
            
            return HttpResponseRedirect("%s" % request.build_absolute_uri())
        
        d = {
            'admin_site': admin_site.name, 
            'title': "Filter proposals for Judges", 
            'opts': "Proposals", 
            'app_label': opts.app_label,
            'awaiting_approval':awaiting_approval
        }
             
        return render_to_response('admin/commissions/proposals/filter_proposals.html', d, context_instance)    
def tag_list(request, template_name = 'blog/tag_list.html', **kwargs):
    """
    Category list

    Template: ``blog/category_list.html``
    Context:
        object_list
            List of categories.
    """
    context = RequestContext(request)
    object_list = Tag.objects.filter(type="editorial")
    tag_list_split = list(split_by(object_list, len(object_list)/2))
    tag_list_left = tag_list_split[0]
    tag_list_right= tag_list_split[1]
    breadcrumb = (("Editorial","/editorial"),("Tags", None))
    
    d = {  
    "tag_list_left":tag_list_left,
    "tag_list_right":tag_list_right,
    "breadcrumb":breadcrumb,
    }
    return render_to_response(template_name, d, context)
Example #5
0
def tag_list(request, template_name = 'blog/tag_list.html', **kwargs):
    """
    Category list

    Template: ``blog/category_list.html``
    Context:
        object_list
            List of categories.
    """
    context = RequestContext(request)
    object_list = Tag.objects.filter(type="editorial")
    tag_list_split = list(split_by(object_list, len(object_list)/2))
    tag_list_left = tag_list_split[0]
    tag_list_right= tag_list_split[1]
    breadcrumb = (("Editorial","/editorial"),("Tags", None))
    
    d = {  
    "tag_list_left":tag_list_left,
    "tag_list_right":tag_list_right,
    "breadcrumb":breadcrumb,
    }
    return render_to_response(template_name, d, context)
Example #6
0
def events(request):
    from models import EVENT_SUB_TYPES
    sub_types = EVENT_SUB_TYPES
    context = RequestContext(request)    
    auto_checks=[]
    sub_types_grouped = list(split_by(sub_types, 3))
    today = datetime.date.today()
    interval =  today + datetime.timedelta(days=365)
        
    if request.GET:
        #check to see if there are multiple filter values or one single filter value
        if len(request.GET) > 1 or request.GET.get("page") == None and not request.GET.get("refresh"):
            filtered_objects = []
            filtered_append = filtered_objects.append
            for get in request.GET:
                if get != "page" and get != "refresh":
                    '''
                    filter objects via get variables
                    '''
                    get_objects = Event.objects.filter(status=1) \
                        .filter(start_date__lte = interval) \
                        .filter(start_date__gte = today) \
                        .filter(subtype = get).filter(status=1) \
                        .order_by("start_date")
                    for object in get_objects:
                        filtered_append(object)
                    auto_checks.append(get)
                                                           
            sorted_objects = sorted(filtered_objects,key=attrgetter('start_date'),reverse=False)   
            events_count = len(sorted_objects)
            events_paginator = RhizomePaginator(sorted_objects, per_page=20, url=request.get_full_path())
                   
        else:
            '''
            just asking for pages, load unfiltered page
            '''
            events = Event.objects \
                .filter(status=1) \
                .filter(start_date__lte = interval) \
                .filter(start_date__gte = today) \
                .order_by("start_date")
            events_count = len(events)
            events_paginator = RhizomePaginator(events, per_page=20, url=request.get_full_path())
            
    else:
        '''
        load normal page
        '''
        events = Event.objects \
            .filter(status=1) \
            .filter(start_date__lte = interval) \
            .filter(start_date__gte = today) \
            .order_by("start_date")
        events_count = len(events)
        events_paginator = RhizomePaginator(events, per_page=20, url=request.get_full_path())
          
    events_paginator.set_current_page(request.GET.get("page"))
    
    d = {
         "include_section_header": True,
         "section_title": "Rhizome Events",
         "section_action": "submit",     
         "announce_paginator":events_paginator,
         "include_section_header":True,
         "events_count":events_count,
         "auto_checks":auto_checks,
         "sub_types_grouped":sub_types_grouped,
         }    
    return render_to_response("announce/events.html",d,context)
Example #7
0
def events(request):
    from models import EVENT_SUB_TYPES
    sub_types = EVENT_SUB_TYPES
    context = RequestContext(request)
    auto_checks = []
    sub_types_grouped = list(split_by(sub_types, 3))
    today = datetime.date.today()
    interval = today + datetime.timedelta(days=365)

    if request.GET:
        #check to see if there are multiple filter values or one single filter value
        if len(request.GET) > 1 or request.GET.get(
                "page") == None and not request.GET.get("refresh"):
            filtered_objects = []
            filtered_append = filtered_objects.append
            for get in request.GET:
                if get != "page" and get != "refresh":
                    '''
                    filter objects via get variables
                    '''
                    get_objects = Event.objects.filter(status=1) \
                        .filter(start_date__lte = interval) \
                        .filter(start_date__gte = today) \
                        .filter(subtype = get).filter(status=1) \
                        .order_by("start_date")
                    for object in get_objects:
                        filtered_append(object)
                    auto_checks.append(get)

            sorted_objects = sorted(filtered_objects,
                                    key=attrgetter('start_date'),
                                    reverse=False)
            events_count = len(sorted_objects)
            events_paginator = RhizomePaginator(sorted_objects,
                                                per_page=20,
                                                url=request.get_full_path())

        else:
            '''
            just asking for pages, load unfiltered page
            '''
            events = Event.objects \
                .filter(status=1) \
                .filter(start_date__lte = interval) \
                .filter(start_date__gte = today) \
                .order_by("start_date")
            events_count = len(events)
            events_paginator = RhizomePaginator(events,
                                                per_page=20,
                                                url=request.get_full_path())

    else:
        '''
        load normal page
        '''
        events = Event.objects \
            .filter(status=1) \
            .filter(start_date__lte = interval) \
            .filter(start_date__gte = today) \
            .order_by("start_date")
        events_count = len(events)
        events_paginator = RhizomePaginator(events,
                                            per_page=20,
                                            url=request.get_full_path())

    events_paginator.set_current_page(request.GET.get("page"))

    d = {
        "include_section_header": True,
        "section_title": "Rhizome Events",
        "section_action": "submit",
        "announce_paginator": events_paginator,
        "include_section_header": True,
        "events_count": events_count,
        "auto_checks": auto_checks,
        "sub_types_grouped": sub_types_grouped,
    }
    return render_to_response("announce/events.html", d, context)
Example #8
0
def opportunities(request):
    from models import OPPORTUNITY_SUB_TYPES
    context = RequestContext(request)
    sub_types = OPPORTUNITY_SUB_TYPES
    auto_checks = []
    sub_types_grouped = list(split_by(sub_types, 4))
    now = datetime.datetime.now()

    if request.GET:
        #check to see if there are multiple filter values or one single filter value
        if len(request.GET) > 1 or request.GET.get(
                "page") == None and not request.GET.get("refresh"):
            filtered_objects = []
            filtered_append = filtered_objects.append
            for get in request.GET:
                if get != "page":
                    get_objects = Opportunity.objects \
                        .filter(subtype = get) \
                        .filter(status = 1) \
                        .filter(deadline__gte = now) \
                        .order_by("deadline")
                    for object in get_objects:
                        filtered_append(object)
                    auto_checks.append(get)

            sorted_objects = sorted(filtered_objects,
                                    key=attrgetter('deadline'))
            opportunities_count = len(sorted_objects)
            opportunites_paginator = RhizomePaginator(
                sorted_objects, per_page=20, url=request.get_full_path())

        else:
            opportunites = Opportunity.objects \
                .filter(status=1) \
                .filter(deadline__gte = now) \
                .order_by("deadline")
            opportunities_count = len(opportunites)
            opportunites_paginator = RhizomePaginator(
                opportunites, per_page=20, url=request.get_full_path())

    else:
        opportunites = Opportunity.objects \
            .filter(status=1) \
            .filter(deadline__gte = now) \
            .order_by("deadline")
        opportunities_count = len(opportunites)
        opportunites_paginator = RhizomePaginator(opportunites,
                                                  per_page=20,
                                                  url=request.get_full_path())

    opportunites_paginator.set_current_page(request.GET.get("page"))

    d = {
        "include_section_header": True,
        "section_title": "Rhizome Opportunities",
        "section_action": "submit",
        "announce_paginator": opportunites_paginator,
        "include_section_header": True,
        "opportunities_count": opportunities_count,
        "auto_checks": auto_checks,
        "sub_types_grouped": sub_types_grouped,
    }

    return render_to_response("announce/opportunities.html", d, context)