Пример #1
0
def add_on_discussion_url_list(request):
    search_url = request.REQUEST.get('search_url', '')
    if search_url:
        active_discussions_by_urgancy_list, locked_discussions_by_relevancy_list = get_discussions_lists()
         
        all_discussions_list  = active_discussions_by_urgancy_list + locked_discussions_by_relevancy_list
        list_title_min_length = 10000
        list_title = None
        applicabale_discussions_list = []
        for discussion in all_discussions_list:
            if can_user_acess_discussion(discussion, request.user):
                if search_url in discussion.parent_url:
                    applicabale_discussions_list.append(discussion)
                    if len(discussion.parent_url) < list_title_min_length:
                        list_title_min_length = len(discussion.parent_url)
                        list_title = discussion.parent_url_text
        if list_title:
            page_name = u'פעילויות שקשורות ל' + list_title
        else:
            page_name = u'פעילויות שקשורות ל' + search_url
             
                         
        return render(request, 'coplay/discussion_url_list.html',
                      {'applicabale_discussions_list': applicabale_discussions_list,
                       'list_title': page_name,
                       'page_name': page_name})
             
    return HttpResponseRedirect(reverse('coplay:discussions_list'))
Пример #2
0
def add_on_discussion_url_list(request):
    search_url = request.REQUEST.get('search_url', '')
    if search_url:
        active_discussions_by_urgancy_list, locked_discussions_by_relevancy_list = get_discussions_lists(
        )

        all_discussions_list = active_discussions_by_urgancy_list + locked_discussions_by_relevancy_list
        list_title_min_length = 10000
        list_title = None
        applicabale_discussions_list = []
        for discussion in all_discussions_list:
            if can_user_acess_discussion(discussion, request.user):
                if search_url in discussion.parent_url:
                    applicabale_discussions_list.append(discussion)
                    if len(discussion.parent_url) < list_title_min_length:
                        list_title_min_length = len(discussion.parent_url)
                        list_title = discussion.parent_url_text
        if list_title:
            page_name = u'פעילויות שקשורות ל' + list_title
        else:
            page_name = u'פעילויות שקשורות ל' + search_url

        return render(
            request, 'coplay/discussion_url_list.html', {
                'applicabale_discussions_list': applicabale_discussions_list,
                'list_title': page_name,
                'page_name': page_name
            })

    return HttpResponseRedirect(reverse('coplay:discussions_list'))
Пример #3
0
 def get_queryset(self):
     active_discussions_by_urgancy_list, locked_discussions_by_relevancy_list = get_discussions_lists()
     
     all_discussions_list  = active_discussions_by_urgancy_list + locked_discussions_by_relevancy_list
     allowed_all_discussions_list = []
     for discussion in all_discussions_list:
         if can_user_acess_discussion(discussion, self.request.user):
             allowed_all_discussions_list.append(discussion)
     
     return (allowed_all_discussions_list)
Пример #4
0
    def get_queryset(self):
        active_discussions_by_urgancy_list, locked_discussions_by_relevancy_list = get_discussions_lists(
        )

        all_discussions_list = active_discussions_by_urgancy_list + locked_discussions_by_relevancy_list
        allowed_all_discussions_list = []
        for discussion in all_discussions_list:
            if can_user_acess_discussion(discussion, self.request.user):
                allowed_all_discussions_list.append(discussion)

        return (allowed_all_discussions_list)
Пример #5
0
def discussion_tag_list(request, pk=None):
    followers = []

    if pk:
        try:
            tag = Tag.objects.get(id=int(pk))
        except Tag.DoesNotExist:
            return render(request, 'coplay/message.html', {
                'message': 'הנושא איננו קיים',
                'rtl': 'dir="rtl"'
            })
        page_name = u'רשימת פעילויות בנושא: ' + tag.name

        for user in User.objects.all():
            if tag.name in user.userprofile.followed_discussions_tags.names():
                followers.append(user)
    else:
        page_name = u'מי צריך עזרה?'
        tag = None

    tags_set = set()
    active_discussions_by_urgancy_list, locked_discussions_by_relevancy_list = get_discussions_lists(
    )

    all_discussions_list = active_discussions_by_urgancy_list + locked_discussions_by_relevancy_list
    allowed_all_discussions_list = []
    for discussion in all_discussions_list:
        if can_user_acess_discussion(discussion, request.user):
            for tag_iter in discussion.tags.all():
                tags_set.add(tag_iter)
            if tag:
                if tag in discussion.tags.all():
                    allowed_all_discussions_list.append(discussion)
            else:
                allowed_all_discussions_list.append(discussion)

    is_following = False
    if request.user.is_authenticated(
    ) and tag and tag in request.user.userprofile.followed_discussions_tags.all(
    ):
        is_following = True

    return render(
        request, 'coplay/discussion_list.html', {
            'latest_discussion_list': allowed_all_discussions_list,
            'tag': tag,
            'page_name': page_name,
            'tags_list': tags_set,
            'tag': tag,
            'is_following': is_following,
            'followers': followers
        })
Пример #6
0
def get_discussion_with_parent_url_list( search_url = None, user = None):
    list_title = None
    applicabale_discussions_list = []
    if search_url:
        active_discussions_by_urgancy_list, locked_discussions_by_relevancy_list = get_discussions_lists()
          
        all_discussions_list  = active_discussions_by_urgancy_list + locked_discussions_by_relevancy_list
        for discussion in all_discussions_list:
            if can_user_acess_discussion(discussion, user):
                if discussion.parent_url and  search_url in discussion.parent_url:
                    applicabale_discussions_list.append(discussion)
                    if discussion.parent_url_text:
                        list_title = discussion.parent_url_text

    return applicabale_discussions_list, list_title
Пример #7
0
def discussion_tag_list(request, pk = None):
    followers = []
    
    if pk:
        try:
            tag = Tag.objects.get(id=int(pk))
        except Tag.DoesNotExist:
            return render(request, 'coplay/message.html',
                          {'message': 'הנושא איננו קיים',
                           'rtl': 'dir="rtl"'})
        page_name = u'רשימת פעילויות בנושא: ' + tag.name
        
        for user in User.objects.all():
            if tag.name in user.userprofile.followed_discussions_tags.names():
                followers.append(user)
    else:
        page_name = u'מי צריך עזרה?'
        tag = None
    

    tags_set = set ()
    active_discussions_by_urgancy_list, locked_discussions_by_relevancy_list = get_discussions_lists()
    
    all_discussions_list  = active_discussions_by_urgancy_list + locked_discussions_by_relevancy_list
    allowed_all_discussions_list = []
    for discussion in all_discussions_list:
        if can_user_acess_discussion(discussion, request.user):
            for tag_iter in discussion.tags.all():
                tags_set.add(tag_iter)
            if tag:
                if tag in discussion.tags.all():
                    allowed_all_discussions_list.append(discussion)
            else:
                allowed_all_discussions_list.append(discussion)
               
    is_following = False
    if request.user.is_authenticated() and tag and tag in request.user.userprofile.followed_discussions_tags.all():
        is_following = True           
        
    
    return render(request, 'coplay/discussion_list.html',
                  {'latest_discussion_list': allowed_all_discussions_list,
                   'tag': tag,
                   'page_name': page_name,
                   'tags_list': tags_set,
                   'tag': tag,
                   'is_following': is_following,
                   'followers': followers})
Пример #8
0
def user_coplay_report(request, username=None):
    if username:
        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            return HttpResponse('User not found')
    else:
        user = request.user

    if not is_in_the_same_segment(user, request.user):
        return render(request, 'coplay/message.html', {
            'message': 'משתמש ממודר',
            'rtl': 'dir="rtl"'
        })

    if user == request.user:
        page_name = u'הפעילות שלי '
    else:
        page_name = u'הפעילות של ' + get_user_fullname_or_username(user)

    open_tasks_list_by_urgancy_list, closed_tasks_list_by_relevancy_list, aborted_tasks_list_by_relevancy_list, missed_tasks_list_by_relevancy_list = get_tasks_lists(
    )

    active_discussions_by_urgancy_list, locked_discussions_by_relevancy_list = get_discussions_lists(
    )

    user_s_open_tasks_list = []
    other_users_open_tasks_list = []
    failed_tasks_list = []
    user_closed_tasks_list = []

    for task in open_tasks_list_by_urgancy_list:
        if can_user_acess_discussion(task.parent, request.user):
            if task.responsible == user:
                user_s_open_tasks_list.append(task)
            else:
                discussion = task.parent
                if user in discussion.get_followers_list():
                    other_users_open_tasks_list.append(task)

    tasks_by_recent_closed_at_date = Task.objects.all().exclude(
        status=Task.MISSED).order_by("-closed_at")

    for task in tasks_by_recent_closed_at_date:
        discussion = task.parent
        if user in discussion.get_followers_list(
        ) and can_user_acess_discussion(discussion, request.user):
            status = task_get_status(task)
            if status == Task.ABORTED:
                failed_tasks_list.append(task)

    number_of_closed_tasks_for_others = 0
    for task in closed_tasks_list_by_relevancy_list:
        if task.responsible == user:
            user_closed_tasks_list.append(task)
            if task.parent.owner != user:
                number_of_closed_tasks_for_others += 1

    user_discussions_active = []
    user_discussions_locked = []

    for discussion in active_discussions_by_urgancy_list:
        if user in discussion.get_followers_list(
        ) and can_user_acess_discussion(discussion, request.user):
            user_discussions_active.append(discussion)

    for discussion in locked_discussions_by_relevancy_list:
        if user in discussion.get_followers_list(
        ) and can_user_acess_discussion(discussion, request.user):
            user_discussions_locked.append(discussion)

    number_of_closed_tasks = len(user_closed_tasks_list)

    number_of_views = 0
    views_list = Viewer.objects.filter(user=user)
    for view in views_list:
        if view.discussion.owner != user:
            number_of_views += view.get_views_counter()

    number_of_feedbacks = user.feedback_set.all().count()
    number_of_votes = user.vote_set.all().count()
    number_of_task_closing = Task.objects.filter(closed_by=user).count()
    number_of_aborted_tasks = Task.objects.filter(status=Task.ABORTED,
                                                  responsible=user).count()

    followers_list = get_followers_list(user)
    following_list = get_following_list(user)
    if request.user.is_authenticated():
        is_following = is_user_is_following(request.user, user)
    else:
        is_following = False

    user_updates_query_set = user.recipient.all().order_by("-created_at")

    return render(
        request, 'coplay/coplay_report.html', {
            'number_of_closed_tasks':
            number_of_closed_tasks,
            'number_of_closed_tasks_for_others':
            number_of_closed_tasks_for_others,
            'number_of_aborted_tasks':
            number_of_aborted_tasks,
            'number_of_task_closing':
            number_of_task_closing,
            'number_of_views':
            number_of_views,
            'number_of_feedbacks':
            number_of_feedbacks,
            'number_of_votes':
            number_of_votes,
            'user_updates_that_viewer_can_access_list':
            user_updates_query_set,
            'tasks_open_by_increased_time_left':
            user_s_open_tasks_list,
            'tasks_others_open_by_increased_time_left':
            other_users_open_tasks_list,
            'discussions_active_by_increase_time_left':
            user_discussions_active,
            'discussions_locked_by_increase_locked_at':
            user_discussions_locked,
            'tasks_closed_by_reverse_time':
            user_closed_tasks_list,
            'tasks_failed_by_reverse_update_time':
            failed_tasks_list,
            'applicabale_user':
            user,
            'followers_list':
            followers_list,
            'following_list':
            following_list,
            'is_following':
            is_following,
            'page_name':
            page_name,
            'description':
            user.userprofile.description,
            'location_desc':
            user.userprofile.location_desc,
            'followed_discussions_tags':
            user.userprofile.followed_discussions_tags.all()
        })
Пример #9
0
def user_coplay_report(request, username=None):
    if username:
        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            return HttpResponse('User not found')        
    else:
        user = request.user
        
    if not is_in_the_same_segment( user, request.user):
        return render(request, 'coplay/message.html', 
                  {  'message'      :  'משתמש ממודר',
                   'rtl': 'dir="rtl"'})

    if user == request.user:
        page_name = u'הפעילות שלי '
    else:
        page_name = u'הפעילות של ' + get_user_fullname_or_username(user)

    open_tasks_list_by_urgancy_list, closed_tasks_list_by_relevancy_list, aborted_tasks_list_by_relevancy_list , missed_tasks_list_by_relevancy_list = get_tasks_lists()

    active_discussions_by_urgancy_list, locked_discussions_by_relevancy_list = get_discussions_lists()

    user_s_open_tasks_list = []
    other_users_open_tasks_list = []
    failed_tasks_list = []
    user_closed_tasks_list = []

    for task in open_tasks_list_by_urgancy_list:  
        if can_user_acess_discussion(task.parent, request.user):      
            if task.responsible == user:
                user_s_open_tasks_list.append(task)
            else:
                discussion = task.parent
                if user in discussion.get_followers_list():
                    other_users_open_tasks_list.append(task)
                
    tasks_by_recent_closed_at_date = Task.objects.all().exclude(status = Task.MISSED).order_by("-closed_at")

    for task in tasks_by_recent_closed_at_date:
        discussion = task.parent
        if user in discussion.get_followers_list() and can_user_acess_discussion(discussion, request.user):
            status = task_get_status(task)
            if status == Task.ABORTED:
                failed_tasks_list.append(task)

    number_of_closed_tasks_for_others = 0
    for task in closed_tasks_list_by_relevancy_list:
        if task.responsible == user:
            user_closed_tasks_list.append(task)
            if task.parent.owner != user:
                number_of_closed_tasks_for_others +=1

    user_discussions_active = []
    user_discussions_locked = []

    for discussion in active_discussions_by_urgancy_list:
        if user in discussion.get_followers_list() and can_user_acess_discussion( discussion, request.user):
            user_discussions_active.append(discussion)

    for discussion in locked_discussions_by_relevancy_list:
        if user in discussion.get_followers_list() and can_user_acess_discussion( discussion, request.user):
            user_discussions_locked.append(discussion)
            
    number_of_closed_tasks = len(user_closed_tasks_list)
    

    number_of_views = 0
    views_list = Viewer.objects.filter( user = user)
    for view in views_list:
        if view.discussion.owner != user:
            number_of_views += view.get_views_counter()
    
    number_of_feedbacks = user.feedback_set.all().count()
    number_of_votes     = user.vote_set.all().count()
    number_of_task_closing = Task.objects.filter( closed_by = user ).count()
    number_of_aborted_tasks = Task.objects.filter( status=Task.ABORTED, responsible = user ).count()
    
    followers_list = get_followers_list(user)
    following_list = get_following_list(user)
    if request.user.is_authenticated():
        is_following = is_user_is_following(request.user, user)
    else:
        is_following = False
        
    user_updates_query_set = user.recipient.all().order_by("-created_at")
            
    return render(request, 'coplay/coplay_report.html',
                  {
                      'number_of_closed_tasks'           : number_of_closed_tasks,
                      'number_of_closed_tasks_for_others': number_of_closed_tasks_for_others,
                      'number_of_aborted_tasks'          : number_of_aborted_tasks,
                      'number_of_task_closing'           : number_of_task_closing,
                      'number_of_views'                  : number_of_views       ,
                      'number_of_feedbacks'              : number_of_feedbacks   ,
                      'number_of_votes'                  : number_of_votes       ,
                      'user_updates_that_viewer_can_access_list': user_updates_query_set,
                      'tasks_open_by_increased_time_left': user_s_open_tasks_list,
                      'tasks_others_open_by_increased_time_left': other_users_open_tasks_list,
                      'discussions_active_by_increase_time_left': user_discussions_active,
                      'discussions_locked_by_increase_locked_at': user_discussions_locked,
                      'tasks_closed_by_reverse_time': user_closed_tasks_list,
                      'tasks_failed_by_reverse_update_time': failed_tasks_list,
                      'applicabale_user': user,
                      'followers_list' :followers_list,
                      'following_list' :following_list,
                      'is_following'   :is_following,
                      'page_name': page_name,
                      'description': user.userprofile.description,
                      'location_desc': user.userprofile.location_desc,
                      'followed_discussions_tags': user.userprofile.followed_discussions_tags.all() } )