Ejemplo n.º 1
0
def jobs(request):
    if request.GET.get("gclid"):
        return HttpResponseRedirect("/announce/jobs/")
        
    from models import JOB_SUB_TYPES
    sub_types = JOB_SUB_TYPES
    context = RequestContext(request) 
    auto_checks=[]
    now = datetime.datetime.now()

    breadcrumb = (('Community', '/community/'), ('Jobs Board', None))
    
    if request.GET:
        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 = Job.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'),reverse=True)   
            jobs_count = len(sorted_objects)
            jobs_paginator = RhizomePaginator(sorted_objects, per_page=20, url=request.get_full_path())
        else:
            jobs = Job.objects \
                .filter(status=1) \
                .filter(deadline__gte = now) \
                .order_by("deadline")
            jobs_count = len(jobs)
            jobs_paginator = RhizomePaginator(jobs, per_page=20, url=request.get_full_path())
                   
    else:
        jobs = Job.objects \
            .filter(status=1) \
            .filter(deadline__gte = now) \
            .order_by("deadline")
        jobs_count = len(jobs)
        jobs_paginator = RhizomePaginator(jobs, per_page=20, url=request.get_full_path())
    
    jobs_paginator.set_current_page(request.GET.get("page"))
        
    d = {"include_section_header": True,
         "section_title": "Rhizome Jobs Board",
         "section_action": "submit",     
         "announce_paginator":jobs_paginator,
         "include_section_header":True,
         "jobs_count":jobs_count,
         "sub_types":sub_types,
         "auto_checks":auto_checks,
         'breadcrumb': breadcrumb
         }
    
    return render_to_response("announce/jobs.html",d,context)
Ejemplo n.º 2
0
def rhizome_search(request, template='search/search.html', load_all=True, form_class=RhizomeHighlightedModelSearchForm, searchqueryset=None, context_class=RequestContext, extra_context=None):
    """
    Custom Search view based off of haystack's basic_search view. Main difference is use of rhizomepaginator
    """
    query = ''
    results = []
    
    if request.GET.get('q'):
        form = form_class(request.GET, searchqueryset=searchqueryset, load_all=load_all)
        
        if form.is_valid():
            query = form.cleaned_data['q']
            results = form.search().order_by('-pub_date')
    else:
        form = form_class(searchqueryset=searchqueryset, load_all=load_all)
    
    search_paginator = RhizomePaginator(results, per_page=RESULTS_PER_PAGE, url=request.get_full_path())
    page = request.GET.get("page")
    search_paginator.set_current_page(request.GET.get("page"))
    
    #breadcrumb = (("Search", None),)
    breadcrumb = None 
     
    context = {
        'form': form,
        'page': page,
        'search_paginator': search_paginator,
        'query': query,
        'breadcrumb': breadcrumb,
    }
    
    if extra_context:
        context.update(extra_context)
    
    return render_to_response(template, context, context_instance=context_class(request))
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
def press(request):
    press = Press.objects.all().order_by('-publication_date')     
    press_paginator = RhizomePaginator(press, per_page=15, url=request.get_full_path())
    press_paginator.set_current_page(request.GET.get('page'))
    
    return render_to_response('about/press.html', {
        'breadcrumb': (('Press', None),),
        'press_paginator': press_paginator,
    }, RequestContext(request))
Ejemplo n.º 5
0
def index(request):
    posts = Post.objects.published().exclude(staff_blog=1).exclude(fp_and_staff_blog=True)
    post_paginator = RhizomePaginator(posts, per_page=8, url=request.get_full_path())
    post_paginator.set_current_page(request.GET.get('page'))
    d = {  
        'post_paginator': post_paginator,
        'current_page_str': str(post_paginator.current_page),
    }
    return render(request, 'blog/post_list.html', d)
Ejemplo n.º 6
0
def index(request):
    posts = Post.objects.published().exclude(staff_blog=1).exclude(fp_and_staff_blog=True)
    post_paginator = RhizomePaginator(posts, per_page=8, url=request.get_full_path())
    post_paginator.set_current_page(request.GET.get('page'))
    d = {  
        'post_paginator': post_paginator,
        'current_page_str': str(post_paginator.current_page),
    }
    return render(request, 'blog/post_list.html', d)
Ejemplo n.º 7
0
def press(request):
    press = Press.objects.all().order_by('-publication_date')
    press_paginator = RhizomePaginator(press,
                                       per_page=15,
                                       url=request.get_full_path())
    press_paginator.set_current_page(request.GET.get('page'))

    return render_to_response('about/press.html', {
        'breadcrumb': (('Press', None), ),
        'press_paginator': press_paginator,
    }, RequestContext(request))
Ejemplo n.º 8
0
def frontpage(request):
    exhibition = FrontpageExhibition.objects.current()
    if exhibition:
        return render(request, 'exhibitions/frontpage_exhibition.html',
                      {'exhibition': exhibition})

    blog_posts = Post.objects.published().exclude(staff_blog=True)
    blog_posts_paginator = RhizomePaginator(blog_posts,
                                            per_page=10,
                                            url='/editorial/')
    blog_posts_paginator.set_current_page(request.GET.get('page'))

    post_list = None
    content = 'editorial'

    if request.GET:
        if len(request.GET) > 1 or request.GET.get('page') == None:
            content = request.GET.get('content')
            if content == 'announce':
                post_list = get_latest_announcements(12)

            if content == 'discuss':
                from discuss.models import get_discusssion_threads
                post_list = get_discusssion_threads(10)

        else:
            fp_paginator = None
            content = 'editorial'

    d = {
        'nobreadcrumb': True,
        'featured_objects': get_featured_objects_list(),
        'comments': ThreadedComment.objects.filter(is_public=True)[:10],
        'content': content,
        'blog_posts_paginator': blog_posts_paginator,
        'post_list': post_list,
    }

    # community campaign modal
    # campaign = CommunityCampaign.objects.current()
    # if campaign:
    #   days_left = campaign.days_left()
    #   if days_left in range(1, 10):
    #     d.update({
    #       'show_campaign_modal': True,
    #       'campaign_days_left': days_left,
    #     })

    return render(request, 'frontpage/frontpage.html', d)
Ejemplo n.º 9
0
def deadlines(request):
    context = RequestContext(request)    
    deadlines = get_announcements_by_deadline()
    announce_paginator = RhizomePaginator(deadlines, per_page=15, url=request.get_full_path())
    page = request.GET.get("page")
    announce_paginator.set_current_page(request.GET.get("page"))
        
    d = {"include_section_header": True,
         "section_title": "Rhizome Announce: Upcoming Deadlines",
         "section_action": "../events/submit",     
         "announce_paginator":announce_paginator,
         "include_section_header":True
         }
    
    return render_to_response("announce/deadlines.html",d,context)
Ejemplo n.º 10
0
def post_archive_month(request, year, month, **kwargs):
    breadcrumb = (("Editorial","/editorial"),("Archives",None))
    context = RequestContext(request)
    tt = time.strptime("%s-%s" % (year, month), '%s-%s' % ('%Y', '%b'))
    date = datetime.date(*tt[:3])
    posts = Post.objects.published().filter(publish__year=year).filter(publish__month=date.month).order_by('publish')
    post_paginator = RhizomePaginator(posts, per_page=10,url=request.get_full_path())
    post_paginator.set_current_page(request.GET.get("page"))
    d = {  
        "post_paginator":post_paginator,
        "date":date,
        "month":date.month,
        "year":year,
        "breadcrumb":breadcrumb
        }
    return render_to_response("blog/archive.html", d, context)
Ejemplo n.º 11
0
def post_archive_month(request, year, month, **kwargs):
    breadcrumb = (("Editorial","/editorial"),("Archives",None))
    context = RequestContext(request)
    tt = time.strptime("%s-%s" % (year, month), '%s-%s' % ('%Y', '%b'))
    date = datetime.date(*tt[:3])
    posts = Post.objects.published().filter(publish__year=year).filter(publish__month=date.month).order_by('publish')
    post_paginator = RhizomePaginator(posts, per_page=10,url=request.get_full_path())
    post_paginator.set_current_page(request.GET.get("page"))
    d = {  
        "post_paginator":post_paginator,
        "date":date,
        "month":date.month,
        "year":year,
        "breadcrumb":breadcrumb
        }
    return render_to_response("blog/archive.html", d, context)
Ejemplo n.º 12
0
def rhizome_search(request,
                   template='search/search.html',
                   load_all=True,
                   form_class=RhizomeHighlightedModelSearchForm,
                   searchqueryset=None,
                   context_class=RequestContext,
                   extra_context=None):
    """
    Custom Search view based off of haystack's basic_search view. Main difference is use of rhizomepaginator
    """
    query = ''
    results = []

    if request.GET.get('q'):
        form = form_class(request.GET,
                          searchqueryset=searchqueryset,
                          load_all=load_all)

        if form.is_valid():
            query = form.cleaned_data['q']
            results = form.search().order_by('-pub_date')
    else:
        form = form_class(searchqueryset=searchqueryset, load_all=load_all)

    search_paginator = RhizomePaginator(results,
                                        per_page=RESULTS_PER_PAGE,
                                        url=request.get_full_path())
    page = request.GET.get("page")
    search_paginator.set_current_page(request.GET.get("page"))

    #breadcrumb = (("Search", None),)
    breadcrumb = None

    context = {
        'form': form,
        'page': page,
        'search_paginator': search_paginator,
        'query': query,
        'breadcrumb': breadcrumb,
    }

    if extra_context:
        context.update(extra_context)

    return render_to_response(template,
                              context,
                              context_instance=context_class(request))
Ejemplo n.º 13
0
def exhibitions_list(request):
    context = RequestContext(request)    
    upcoming_exhibitions = get_upcoming_exhibitions()
    past_exhibitions = get_past_exhibitions()    
    past_exhibitions_paginator = RhizomePaginator(past_exhibitions, per_page=7, url=request.get_full_path())
    past_exhibitions_paginator.set_current_page(request.GET.get("page"))

    breadcrumb = (('Programs', '/programs/'), ('Exhibition', None))

    return render_to_response(
        "programs/exhibitions_list.html", {
            "past_exhibitions_paginator":past_exhibitions_paginator,
            "upcoming_exhibitions":upcoming_exhibitions,
            'breadcrumb': breadcrumb
        },
        context
    )
Ejemplo n.º 14
0
def profiles_list(request):
    context = RequestContext(request)
    sort = request.GET.get("sort")

    breadcrumb = (
        ('Community', '/community/'),
        ('Profiles', None),
    )

    if sort:
        users = RhizomeUser.objects \
                .filter( \
                    Q(last_name__istartswith=sort) | \
                    Q(first_name__istartswith=sort) | \
                    Q(username__istartswith=sort) \
                ) \
                .filter(visible=True) \
                .filter(is_active=True) \
                .order_by('user__username', 'user__first_name', 'user__last_name')

        cleaned_users = remove_duplicates_and_preserve_order(users)
        accounts_paginator = RhizomePaginator(cleaned_users,
                                              per_page=150,
                                              url=request.get_full_path())

    else:
        users = RhizomeUser.objects \
            .filter(visible=True) \
            .filter(is_active=True) \
            .order_by('-user_rating__rating', 'user__username', 'user__first_name', 'user__last_name')

        accounts_paginator = RhizomePaginator(users,
                                              per_page=150,
                                              url=request.get_full_path())

    alphabet = [chr(i) for i in xrange(ord('a'), ord('z') + 1)]

    return render_to_response(
        "accounts/profiles_list.html", {
            "accounts_paginator": accounts_paginator,
            "alphabet": alphabet,
            "sort": sort,
            "updated_portfolios": get_recently_updated_portfolios(45),
            "grouped": browse_helper(request, accounts_paginator),
            'breadcrumb': breadcrumb
        }, context)
Ejemplo n.º 15
0
def exhibitions_list(request):
    context = RequestContext(request)
    upcoming_exhibitions = get_upcoming_exhibitions()
    past_exhibitions = get_past_exhibitions()
    past_exhibitions_paginator = RhizomePaginator(past_exhibitions,
                                                  per_page=7,
                                                  url=request.get_full_path())
    past_exhibitions_paginator.set_current_page(request.GET.get("page"))

    breadcrumb = (('Programs', '/programs/'), ('Exhibition', None))

    return render_to_response(
        "programs/exhibitions_list.html", {
            "past_exhibitions_paginator": past_exhibitions_paginator,
            "upcoming_exhibitions": upcoming_exhibitions,
            'breadcrumb': breadcrumb
        }, context)
Ejemplo n.º 16
0
def frontpage(request):
    exhibition = FrontpageExhibition.objects.current()
    if exhibition:
        return render(request, 'exhibitions/frontpage_exhibition.html', {'exhibition': exhibition})

    blog_posts = Post.objects.published().exclude(staff_blog=True)
    blog_posts_paginator = RhizomePaginator(blog_posts, per_page=10, url='/editorial/')
    blog_posts_paginator.set_current_page(request.GET.get('page'))

    post_list = None
    content = 'editorial'
            
    if request.GET:
        if len(request.GET) > 1 or request.GET.get('page') == None:
            content = request.GET.get('content')
            if content == 'announce':
                post_list = get_latest_announcements(12)
                
            if content == 'discuss':
                from discuss.models import get_discusssion_threads
                post_list = get_discusssion_threads(10)
    
        else:
           fp_paginator = None
           content = 'editorial'

    d = {
        'nobreadcrumb': True,
        'featured_objects': get_featured_objects_list(),
        'comments': ThreadedComment.objects.filter(is_public=True)[:10],
        'content': content,
        'blog_posts_paginator': blog_posts_paginator,
        'post_list': post_list,
    }
                               
    # community campaign modal
    # campaign = CommunityCampaign.objects.current()
    # if campaign:
    #   days_left = campaign.days_left()
    #   if days_left in range(1, 10):
    #     d.update({
    #       'show_campaign_modal': True,
    #       'campaign_days_left': days_left,
    #     })
    
    return render(request, 'frontpage/frontpage.html', d)
Ejemplo n.º 17
0
def index(request):
    context = RequestContext(request)    
    announcements = get_latest_announcements()
    announce_paginator = RhizomePaginator(announcements, per_page=15, url=request.get_full_path())
    page = request.GET.get("page")
    announce_paginator.set_current_page(request.GET.get("page"))

    breadcrumb = (('Community', '/community/'), ('Announce', None))
        
    d = {"include_section_header": True,
         "section_title": "Rhizome Announce",
         "section_action": "submit",     
         "announce_paginator":announce_paginator,
         "include_section_header":True,
         'breadcrumb': breadcrumb
         }
    
    return render_to_response("announce/index.html",d,context)
Ejemplo n.º 18
0
def events_list(request):
    context = RequestContext(request)    
    events = RhizEvent.objects.all().order_by("-start_date")
    upcoming_events = get_upcoming_events()
    past_events = get_past_events()
    past_events_paginator = RhizomePaginator(past_events, per_page=7, url=request.get_full_path())
    past_events_paginator.set_current_page(request.GET.get("page"))

    breadcrumb = (('Programs', '/programs/'), ('Events', None))

    return render_to_response(
        "programs/events_list.html", {
            "upcoming_events":upcoming_events,
            "past_events_paginator":past_events_paginator,
            'breadcrumb': breadcrumb
        },
        context
    )
Ejemplo n.º 19
0
def events_list(request):
    context = RequestContext(request)
    events = RhizEvent.objects.all().order_by("-start_date")
    upcoming_events = get_upcoming_events()
    past_events = get_past_events()
    past_events_paginator = RhizomePaginator(past_events,
                                             per_page=7,
                                             url=request.get_full_path())
    past_events_paginator.set_current_page(request.GET.get("page"))

    breadcrumb = (('Programs', '/programs/'), ('Events', None))

    return render_to_response(
        "programs/events_list.html", {
            "upcoming_events": upcoming_events,
            "past_events_paginator": past_events_paginator,
            'breadcrumb': breadcrumb
        }, context)
Ejemplo n.º 20
0
def index(request):
    discussion_threads = DiscussionThread.objects.filter(is_public=True)
    discussion_paginator = RhizomePaginator(discussion_threads, per_page=25, url=request.get_full_path())

    breadcrumb = (('Community', '/community/'), ('Discuss', None))
    
    page = request.GET.get('page')
    if not page or page.isdigit() == False:
        page = 1
    discussion_paginator.set_current_page(int(page))
        
    return render(request, 'discuss/index.html', {
        'include_section_header': True,
        'section_title': 'Rhizome Discuss',
        'section_action': 'submit',     
        'discussion_paginator': discussion_paginator,
        'breadcrumb': breadcrumb
    })
Ejemplo n.º 21
0
def deadlines(request):
    context = RequestContext(request)
    deadlines = get_announcements_by_deadline()
    announce_paginator = RhizomePaginator(deadlines,
                                          per_page=15,
                                          url=request.get_full_path())
    page = request.GET.get("page")
    announce_paginator.set_current_page(request.GET.get("page"))

    d = {
        "include_section_header": True,
        "section_title": "Rhizome Announce: Upcoming Deadlines",
        "section_action": "../events/submit",
        "announce_paginator": announce_paginator,
        "include_section_header": True
    }

    return render_to_response("announce/deadlines.html", d, context)
Ejemplo n.º 22
0
def tag_detail(request, slug, template_name = 'blog/tag_detail.html', **kwargs):
    """
    Tag detail

    Template: ``blog/tag_detail.html``
    Context:
        object_list
            List of posts specific to the given tag.
        tag
            Given tag.
    """
    
    # gotta add in some exception handling in case of duplicate tags
    tag = None
    
    try:
        tag = get_object_or_404(Tag, slug=slug, type="editorial")
    except:
        tags = Tag.objects.filter(slug=slug, type="editorial")[:1]
        for t in tags:
            tag = t
        
    if tag:
        queryset = TaggedItem.objects.get_by_model(Post, tag).filter(status=2).filter(publish__lte=datetime.datetime.now())
        if queryset:
            context = RequestContext(request)
            post_paginator = RhizomePaginator(queryset, per_page=10, url=request.get_full_path())
            page = request.GET.get("page")
            post_paginator.set_current_page(request.GET.get("page"))
            breadcrumb =  (("Editorial","/editorial"),("Tags", "/editorial/tags"),(tag.name,None))
        else:
            return HttpResponseRedirect("/editorial/")
    else:
        raise Http404
    
    d = {  
        "tag":tag,
        "post_paginator":post_paginator,
        "breadcrumb":breadcrumb,
        }
    return render_to_response(template_name, d, context)
Ejemplo n.º 23
0
def tag_detail(request, slug, template_name = 'blog/tag_detail.html', **kwargs):
    """
    Tag detail

    Template: ``blog/tag_detail.html``
    Context:
        object_list
            List of posts specific to the given tag.
        tag
            Given tag.
    """
    
    # gotta add in some exception handling in case of duplicate tags
    tag = None
    
    try:
        tag = get_object_or_404(Tag, slug=slug, type="editorial")
    except:
        tags = Tag.objects.filter(slug=slug, type="editorial")[:1]
        for t in tags:
            tag = t
        
    if tag:
        queryset = TaggedItem.objects.get_by_model(Post, tag).filter(status=2).filter(publish__lte=datetime.datetime.now())
        if queryset:
            context = RequestContext(request)
            post_paginator = RhizomePaginator(queryset, per_page=10, url=request.get_full_path())
            page = request.GET.get("page")
            post_paginator.set_current_page(request.GET.get("page"))
            breadcrumb =  (("Editorial","/editorial"),("Tags", "/editorial/tags"),(tag.name,None))
        else:
            return HttpResponseRedirect("/editorial/")
    else:
        raise Http404
    
    d = {  
        "tag":tag,
        "post_paginator":post_paginator,
        "breadcrumb":breadcrumb,
        }
    return render_to_response(template_name, d, context)
Ejemplo n.º 24
0
def index(request):
    context = RequestContext(request)
    announcements = get_latest_announcements()
    announce_paginator = RhizomePaginator(announcements,
                                          per_page=15,
                                          url=request.get_full_path())
    page = request.GET.get("page")
    announce_paginator.set_current_page(request.GET.get("page"))

    breadcrumb = (('Community', '/community/'), ('Announce', None))

    d = {
        "include_section_header": True,
        "section_title": "Rhizome Announce",
        "section_action": "submit",
        "announce_paginator": announce_paginator,
        "include_section_header": True,
        'breadcrumb': breadcrumb
    }

    return render_to_response("announce/index.html", d, context)
Ejemplo n.º 25
0
def post_archive_year(request, year=None):
    breadcrumb = (("Editorial","/editorial"),("Archives",None))

    context = RequestContext(request)
    if year:
        posts = Post.objects.published().filter(publish__year=year).order_by('-publish')
    else:
        latest_blog_date = blog_archive_years = Post.objects.dates('publish', 'year', order='DESC')[:1]
        for dates in latest_blog_date:
            year = dates.year
        posts = Post.objects.published().filter(publish__year=year).order_by('-publish')
    
    post_paginator = RhizomePaginator(posts, per_page=10,url=request.get_full_path())
    post_paginator.set_current_page(request.GET.get("page"))
    
    d = {  
        "post_paginator":post_paginator,
        "year":year,
        "breadcrumb":breadcrumb
        }
    
    return render_to_response("blog/archive.html", d, context)
Ejemplo n.º 26
0
def post_archive_year(request, year=None):
    breadcrumb = (("Editorial","/editorial"),("Archives",None))

    context = RequestContext(request)
    if year:
        posts = Post.objects.published().filter(publish__year=year).order_by('-publish')
    else:
        latest_blog_date = blog_archive_years = Post.objects.dates('publish', 'year', order='DESC')[:1]
        for dates in latest_blog_date:
            year = dates.year
        posts = Post.objects.published().filter(publish__year=year).order_by('-publish')
    
    post_paginator = RhizomePaginator(posts, per_page=10,url=request.get_full_path())
    post_paginator.set_current_page(request.GET.get("page"))
    
    d = {  
        "post_paginator":post_paginator,
        "year":year,
        "breadcrumb":breadcrumb
        }
    
    return render_to_response("blog/archive.html", d, context)
Ejemplo n.º 27
0
def portfolios(request):
    context = RequestContext(request)
    
    breadcrumb = (("Community", "/community"),("Portfolios",None))

    portfolios = get_recently_updated_portfolios()
    
    portfolios_paginator = RhizomePaginator(portfolios, per_page=50, url=request.get_full_path())
            
   
    d= {
        "breadcrumb":breadcrumb,
        "portfolios_paginator": portfolios_paginator,
        "grouped": browse_helper(request, portfolios_paginator),       
     }
    
    return render_to_response("accounts/portfolios.html", d, context)
Ejemplo n.º 28
0
def user_profile(request, user):  
    context = RequestContext(request)
    try:
        #in case the url has a user id, send it back to this view with username
        user = get_object_or_404(User, pk=user)
        return HttpResponseRedirect(user_profile, kwargs={"username": user.username})
    except:
        #now really get it
        user = get_object_or_404(User, username=user)
    
    breadcrumb = (("Community","/community"),("%s" % user.get_profile(),None))
    
    if not user.is_active or not user.get_profile().visible: 
        return HttpResponseRedirect("/profiles/anonymous")
        
    address = user.get_profile().address()
    is_member = user.get_profile().is_rhizomemember()
    portfolio = user.get_profile().get_portfolio()
    exhibitions = user.get_profile().get_member_exhibitions()
    saved_works = user.get_profile().get_saved_artworks()
    
    blog_posts = user.get_profile().get_blog_posts_for_profile()  
    if blog_posts:
        blog_posts_pages = RhizomePaginator(blog_posts, per_page=5, custom_page_param = "posts", anchor_name="blog_posts", url=request.get_full_path() )
        blog_posts_pages.set_current_page(request.GET.get("posts"))
    else:
        blog_posts_pages = None
    
    #activity stream
    activities = user.get_profile().get_all_activity_stream()
    activities_count = user.get_profile().get_activity_stream_counts(activities)
    auto_checks=[]         
    
    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("posts"):    
            filtered_activities = []
            filtered_activities_append = filtered_activities.append

            for get in request.GET:
                if get != "page" and get !="posts":
                    #grab the requested objects and put them in a list
                    auto_checks.append(get)   
                    if get == "discuss":
                        get = 'Threaded comment'
                    for item in activities:
                        if item.content_type.name == get:
                            filtered_activities_append(item)

            activities = sorted(filtered_activities,key=attrgetter('created'),reverse=True)         
    if activities:
        activities_paginator = RhizomePaginator(activities, per_page=5, anchor_name="activity_stream",url=request.get_full_path())
        activities_paginator.set_current_page(request.GET.get("page"))
    else:
        activities_paginator = None
     
    return render_to_response(
        "accounts/user_profile.html", 
        {"include_object_header": True,
        "user":user,
        "is_member":is_member,
        "portfolio":portfolio,
        "activities_count":activities_count,
        "auto_checks":auto_checks,
        "activities_paginator":activities_paginator,
        "exhibitions":exhibitions,
        "breadcrumb":breadcrumb,
        "saved_works":saved_works,
        "blog_posts_pages":blog_posts_pages
        },
        context
    )
Ejemplo n.º 29
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)
Ejemplo n.º 30
0
def jobs(request):
    if request.GET.get("gclid"):
        return HttpResponseRedirect("/announce/jobs/")

    from models import JOB_SUB_TYPES
    sub_types = JOB_SUB_TYPES
    context = RequestContext(request)
    auto_checks = []
    now = datetime.datetime.now()

    breadcrumb = (('Community', '/community/'), ('Jobs Board', None))

    if request.GET:
        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 = Job.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'),
                                    reverse=True)
            jobs_count = len(sorted_objects)
            jobs_paginator = RhizomePaginator(sorted_objects,
                                              per_page=20,
                                              url=request.get_full_path())
        else:
            jobs = Job.objects \
                .filter(status=1) \
                .filter(deadline__gte = now) \
                .order_by("deadline")
            jobs_count = len(jobs)
            jobs_paginator = RhizomePaginator(jobs,
                                              per_page=20,
                                              url=request.get_full_path())

    else:
        jobs = Job.objects \
            .filter(status=1) \
            .filter(deadline__gte = now) \
            .order_by("deadline")
        jobs_count = len(jobs)
        jobs_paginator = RhizomePaginator(jobs,
                                          per_page=20,
                                          url=request.get_full_path())

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

    d = {
        "include_section_header": True,
        "section_title": "Rhizome Jobs Board",
        "section_action": "submit",
        "announce_paginator": jobs_paginator,
        "include_section_header": True,
        "jobs_count": jobs_count,
        "sub_types": sub_types,
        "auto_checks": auto_checks,
        'breadcrumb': breadcrumb
    }

    return render_to_response("announce/jobs.html", d, context)
Ejemplo n.º 31
0
def user_profile(request, user):  
    context = RequestContext(request)
    try:
        #in case the url has a user id, send it back to this view with username
        user = get_object_or_404(User, pk=user)
        return HttpResponseRedirect(user_profile, kwargs={"username": user.username})
    except:
        #now really get it
        user = get_object_or_404(User, username=user)
    
    breadcrumb = (("Community","/community"),("%s" % user.get_profile(),None))
    
    if not user.is_active or not user.get_profile().visible: 
        return HttpResponseRedirect("/profiles/anonymous")
        
    address = user.get_profile().address()
    is_member = user.get_profile().is_rhizomemember()
    portfolio = user.get_profile().get_portfolio()
    artbase_portfolio = user.get_profile().get_artbase_portfolio()
    exhibitions = user.get_profile().get_member_exhibitions()
    saved_works = user.get_profile().get_saved_artworks()
    
    blog_posts = user.get_profile().get_blog_posts_for_profile()  
    if blog_posts:
        blog_posts_pages = RhizomePaginator(blog_posts, per_page=5, custom_page_param = "posts", anchor_name="blog_posts", url=request.get_full_path() )
        blog_posts_pages.set_current_page(request.GET.get("posts"))
    else:
        blog_posts_pages = None
    
    #activity stream
    activities = user.get_profile().get_all_activity_stream()
    activities_count = user.get_profile().get_activity_stream_counts(activities)
    auto_checks=[]         
    
    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("posts"):    
            filtered_activities = []
            filtered_activities_append = filtered_activities.append

            for get in request.GET:
                if get != "page" and get !="posts":
                    #grab the requested objects and put them in a list
                    auto_checks.append(get)   
                    if get == "discuss":
                        get = 'Threaded comment'
                    for item in activities:
                        if item.content_type.name == get:
                            filtered_activities_append(item)

            activities = sorted(filtered_activities,key=attrgetter('created'),reverse=True)         
    if activities:
        activities_paginator = RhizomePaginator(activities, per_page=5, anchor_name="activity_stream",url=request.get_full_path())
        activities_paginator.set_current_page(request.GET.get("page"))
    else:
        activities_paginator = None
     
    return render_to_response(
        "accounts/user_profile.html", 
        {"include_object_header": True,
        "user":user,
        "is_member":is_member,
        "portfolio":portfolio,
        "artbase_portfolio":artbase_portfolio,
        "activities_count":activities_count,
        "auto_checks":auto_checks,
        "activities_paginator":activities_paginator,
        "exhibitions":exhibitions,
        "breadcrumb":breadcrumb,
        "saved_works":saved_works,
        "blog_posts_pages":blog_posts_pages
        },
        context
    )
Ejemplo n.º 32
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)
Ejemplo n.º 33
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)