Example #1
0
def visualize(request, discussion_slug):
    user = request.user
    discussion = Discussion.objects.select_related(depth=1).get(slug=discussion_slug)
    group = GroupProfile.objects.get(group=discussion.group)
    stories = discussion.stories
    user_in_group = group.is_user_in_group(request.user)
    voting = Voting.objects.get_started(discussion=discussion)
    if voting:
        has_voting = True
        voting_data = get_voting_data(user, voting, discussion)
        if voting_data is False:
            has_voting = False
    if discussion.is_private and not group.is_user_in_group(user):
        messages.error(request, "The discussion is private. You're not allowed to see it." )
    if str(user) != 'AnonymousUser':
        user_follows_discussion = True if user.subscriptions.filter(discussion=discussion) else False
    else:
        user_follows_discussion = False
    speech_acts = SpeechAct.objects.filter(discussion_type=discussion.type)
    opinion_types = speech_acts.filter(story_type=2)
    last_related_update = str(discussion.last_related_update) # set an initial value for the update timestamp
    user_permissions = get_user_permissions(request.user, group)
    if user_permissions != 3 and user_permissions != "Not logged in":
        user_permissions = 'allowed'
    else:
        user_permissions = ''
    hints_metadata = get_hints_metadata(discussion)
    return render_to_response('discussion_home.html', locals(), context_instance=RequestContext(request))
Example #2
0
def group_home(request, group_slug):
    """
    Homepage of a group, displaying the group's description & active content.
    """
    user = request.user
    group = GroupProfile.objects.get(slug=group_slug)
    user_permissions = ''
    if not group:
        raise Http404("Can't find a group with the slug: %s" % group_slug)
    else:
        user_permission_type = get_user_permissions(user, group)
        if user_permission_type != 3 and user_permission_type != "Not logged in":
            user_permissions = 'allowed'
    query = group.mission_statements.all().order_by("-created_at")
    if query.count() > 0:
        mission_statement = query[0]
    else:
        mission_statement = ""
    discussions = group.group.discussions.all()
    members = group.get_group_members()
    user_in_group = group.is_user_in_group(user)
    if group.is_private and not user_in_group:
        messages.error(request, "The group is private. You're not allowed to see it." )
    #initializing the forms
    discussion_form = DiscussionForm()
    mission_statement_form = MissionStatementForm()
    return render_to_response('group_home.html', locals(), context_instance=RequestContext(request))
Example #3
0
def group_settings(request, group_slug):
    group = GroupProfile.objects.get(slug=group_slug)
    user_in_group = group.is_user_in_group(request.user)
    members = group.get_group_members()
    if not group:
        raise Http404("Can't find a group with the slug: %s" % group_slug)
    else:
        user_permission_type = get_user_permissions(request.user, group)
    return render_to_response('group_settings.html', locals(), context_instance=RequestContext(request))