Ejemplo n.º 1
0
def text_followup(request, key):
    text = get_text_by_keys_or_404(key)
    user = request.user if request.user.is_authenticated() else None

    from cm.security import user_has_perm # import here!
    anonymous_can_view_text = user_has_perm(None, 'can_view_text', text=text)
    text_notify_check = Notification.objects.filter(text=text,type='text',user=user, active=True).count()
    workspace_notify_check = Notification.objects.filter(text=None,type='workspace',user=user, active=True).count()
    
    if request.method == 'POST':
        if 'activate' in request.POST:
            text.private_feed_key = generate_key()
            text.save()
            display_message(request, _(u"Private feed activated."))            
        if 'reset' in request.POST:
            text.private_feed_key = generate_key()
            text.save()
            display_message(request, _(u"Private notifications feed reseted."))
            
        if request.POST.get('notif_id',None):
            notif_id = request.POST.get('notif_id')
            notif_val = request.POST.get(notif_id,None)
            if notif_val != None :
                Notification.objects.set_notification(text=text, type='text', active=(notif_val == 'true'), email_or_user=request.user)

    template_dict = {
                     'text' : text,
                     'workspace_notify_check' : workspace_notify_check,
                     'text_notify_check' : text_notify_check,
                     'anonymous_can_view_text' : anonymous_can_view_text,
                     }
    return render_to_response('site/text_followup.html', template_dict , context_instance=RequestContext(request))
Ejemplo n.º 2
0
def followup(request):
    user = get_request_user(request)
    workspace_notify_check = Notification.objects.filter(text=None,
                                                         type='workspace',
                                                         user=user,
                                                         active=True).count()
    own_notify_check = Notification.objects.filter(text=None,
                                                   type='own',
                                                   user=user,
                                                   active=True).count()

    if request.method == 'POST':
        if 'activate' in request.POST:
            Configuration.objects.set_key('private_feed_key', generate_key())
            display_message(request, _(u"Private feed activated."))
        if 'reset' in request.POST:
            Configuration.objects.set_key('private_feed_key', generate_key())
            display_message(request, _(u"Private feed reseted."))
        if request.POST.get('notif_id', None):
            notif_id = request.POST.get('notif_id')
            notif_type = 'own' if notif_id == 'own_notify_check' else 'workspace'
            notif_val = request.POST.get(notif_id, None)
            if notif_val != None:
                Notification.objects.set_notification(
                    text=None,
                    type=notif_type,
                    active=(notif_val == 'true'),
                    email_or_user=user)

    return render_to_response('site/followup.html', {
        'workspace_notify_check': workspace_notify_check,
        'own_notify_check': own_notify_check,
    },
                              context_instance=RequestContext(request))
Ejemplo n.º 3
0
def text_followup(request, key):
    text = get_text_by_keys_or_404(key)
    user = request.user if request.user.is_authenticated() else None

    from cm.security import user_has_perm  # import here!
    anonymous_can_view_text = user_has_perm(None, 'can_view_text', text=text)
    text_notify_check = Notification.objects.filter(text=text,
                                                    type='text',
                                                    user=user,
                                                    active=True).count()
    workspace_notify_check = Notification.objects.filter(text=None,
                                                         type='workspace',
                                                         user=user,
                                                         active=True).count()

    if request.method == 'POST':
        if 'activate' in request.POST:
            text.private_feed_key = generate_key()
            text.save()
            display_message(request, _(u"Private feed activated."))
        if 'reset' in request.POST:
            text.private_feed_key = generate_key()
            text.save()
            display_message(request, _(u"Private notifications feed reseted."))

        if request.POST.get('notif_id', None):
            notif_id = request.POST.get('notif_id')
            notif_val = request.POST.get(notif_id, None)
            if notif_val != None:
                Notification.objects.set_notification(
                    text=text,
                    type='text',
                    active=(notif_val == 'true'),
                    email_or_user=request.user)

    template_dict = {
        'text': text,
        'workspace_notify_check': workspace_notify_check,
        'text_notify_check': text_notify_check,
        'anonymous_can_view_text': anonymous_can_view_text,
    }
    return render_to_response('site/text_followup.html',
                              template_dict,
                              context_instance=RequestContext(request))
Ejemplo n.º 4
0
def followup(request):
    user = get_request_user(request)
    workspace_notify_check = Notification.objects.filter(text=None,type='workspace',user=user, active=True).count()
    own_notify_check = Notification.objects.filter(text=None,type='own',user=user, active=True).count()
    
    if request.method == 'POST':
        if 'activate' in request.POST:
            Configuration.objects.set_key('private_feed_key', generate_key())
            display_message(request, _(u"Private feed activated."))            
        if 'reset' in request.POST:
            Configuration.objects.set_key('private_feed_key', generate_key())
            display_message(request, _(u"Private feed reseted."))            
        if request.POST.get('notif_id',None):
            notif_id = request.POST.get('notif_id')
            notif_type = 'own' if notif_id == 'own_notify_check' else 'workspace' 
            notif_val = request.POST.get(notif_id,None)
            if notif_val != None :
                Notification.objects.set_notification(text=None, type=notif_type, active=(notif_val == 'true'), email_or_user=user)
    
    return render_to_response('site/followup.html', {'workspace_notify_check':workspace_notify_check,
                                                          'own_notify_check' :own_notify_check, 
                                                          }, context_instance=RequestContext(request))