예제 #1
0
def project_wall(request, project, discussion_area=False):
    is_organizing = project.is_organizing(request.user)
    is_participating = project.is_participating(request.user)
    if is_organizing:
        form = statuses_forms.ImportantStatusForm()
    elif is_participating:
        form = statuses_forms.StatusForm()
    else:
        form = None

    activities = project.activities()
    if discussion_area:
        activities = apply_filter(activities, 'messages')
    else:
        activities = filter_activities(request, activities)

    if project.category == Project.CHALLENGE:
        url = reverse('projects_discussion_area',
            kwargs=dict(slug=project.slug))
    else:
        url = project.get_absolute_url()

    context = {
        'request': request,
        'user': request.user,
        'project': project,
        'participating': is_participating,
        'organizing': is_organizing,
        'form': form,
        'discussion_area': discussion_area,
        'domain': Site.objects.get_current().domain,
        'wall_url': url,
    }
    context.update(get_pagination_context(request, activities))
    return context
예제 #2
0
파일: views.py 프로젝트: AndyHendy/lernanta
def show(request, slug):
    project = get_object_or_404(Project, slug=slug)
    user = request.user
    can_post_wall = user.is_superuser
    form = None
    if user.is_authenticated():
        profile = request.user.get_profile()
        can_post_wall = can_post_wall or (profile == project.created_by)
        if can_post_wall:
            form = statuses_forms.ImportantStatusForm()
        can_post_wall = can_post_wall or project.participants().filter(
            user=profile).exists()
        if not form and can_post_wall:
            form = statuses_forms.StatusForm()
    challenges = Challenge.objects.active(project_id=project.id)
    context = {
        'project': project,
        'activities': project.activities()[0:10],
        'can_post_wall': can_post_wall,
        'challenges': challenges,
        'form': form,
    }
    return render_to_response('projects/project.html',
                              context,
                              context_instance=RequestContext(request))
예제 #3
0
def show(request, slug, page=1):
    project = get_object_or_404(Project, slug=slug)
    is_organizing = project.is_organizing(request.user)
    is_participating = project.is_participating(request.user)
    is_following = project.is_following(request.user)
    content_pages = Page.objects.filter(project__pk=project.pk,
                                        listed=True,
                                        deleted=False).order_by('index')
    content_pages_for_header = content_pages[0:3]
    content_pages_count = len(content_pages)
    if request.user.is_authenticated():
        is_pending_signup = project.is_pending_signup(
            request.user.get_profile())
    else:
        is_pending_signup = False
    if is_organizing:
        form = statuses_forms.ImportantStatusForm()
    elif is_participating:
        form = statuses_forms.StatusForm()
    else:
        form = None

    activities = project.activities()
    paginator = Paginator(activities, 10)
    try:
        current_page = paginator.page(page)
    except EmptyPage:
        raise http.Http404

    context = {
        'project': project,
        'participating': is_participating,
        'following': is_following,
        'pending_signup': is_pending_signup,
        'organizing': is_organizing,
        'content_pages_for_header': content_pages_for_header,
        'content_pages_count': content_pages_count,
        'form': form,
        'paginator': paginator,
        'page_num': page,
        'next_page': int(page) + 1,
        'prev_page': int(page) - 1,
        'num_pages': paginator.num_pages,
        'page': current_page,
        'domain': Site.objects.get_current().domain,
    }
    return render_to_response('projects/project.html',
                              context,
                              context_instance=RequestContext(request))
예제 #4
0
def show(request, slug):
    project = get_object_or_404(Project, slug=slug)
    is_organizing = project.is_organizing(request.user)
    is_participating = project.is_participating(request.user)
    if is_organizing:
        form = statuses_forms.ImportantStatusForm()
    elif is_participating:
         form = statuses_forms.StatusForm()
    else:
        form = None
    # TODO: See how we can modify and use challenges.
    challenges = Challenge.objects.upcoming(project_id=project.id)
    
    context = {
        'project': project,
        'activities': project.activities()[0:10],
        'participating': is_participating,
        'organizing': is_organizing,
        'challenges': challenges,
        'form': form,
    }
    return render_to_response('projects/project.html', context,
                              context_instance=RequestContext(request))