Example #1
0
def addnote(request, id):
    client = get_object_or_404(Client, id=id, using=request.server)
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            # penalty type in db is defined as enum.
            # so we treat a comment like an inactive notice with a special keyword
            p = Penalty(client=client,
                        type=PENALTY_TYPE_NOTICE,
                        keyword=TYPE_COMMENT,
                        inactive=1,
                        duration=0,
                        reason= form.cleaned_data['reason'],
                        time_edit=datetime.datetime.now(),
                        time_add=datetime.datetime.now(),
                        data= "UP#%s" % request.user.username,
                        admin_id=0)
            p.save(using=request.server)
            Auditor.objects.create(user=request.user,
                                   server_id=request.server,
                                   clientid=client.id,
                                   message=_("Add \"%s\"") % str(p))
            messages.success(request, _('Comment added successfully.'))
            return HttpResponse("{\"sucess\": true}",  mimetype='application/json') 
    else:
        form = CommentForm()
        url = urlreverse("add_note", server=request.server, kwargs={'id':id})
    return {'form': form, 'client': client, 'url': url}
Example #2
0
def remove(request, id):
    client = get_object_or_404(Client, id=id, using=request.server)
    if client.followed.all():
        for r in client.followed.all():
            r.delete()

        Auditor.objects.create(user=request.user,
                               server_id=request.server,
                               clientid=client.id,
                               message=_("Remove from watch list"))
                    
        messages.success(request, _('User removed of the watch list'))    
    else:
        messages.error(request, _('User is not in the watch list'))

    if request.GET.has_key('ls'):
        return HttpResponseRedirect(urlreverse("follow:home",server=request.server))
    else:
        return HttpResponseRedirect(urlreverse("client_detail",server=request.server,kwargs={'id': id}))    
Example #3
0
def add(request, id):
    client = get_object_or_404(Client, id=id, using=request.server)
    if request.method == 'POST':
        form = FollowForm(request.POST)
        if form.is_valid():
            p = Follow.objects.using(request.server).create(client=client,
                       reason=_("%(reason)s (by %(user)s)") % {'reason': form.cleaned_data['reason'], 'user': request.user},
                       time_add=datetime.datetime.now(),
                       admin_id=0)
            messages.success(request, _('Follow added successfully.'))
            
            Auditor.objects.create(user=request.user,
                                   server_id=request.server,
                                   clientid=client.id,
                                   message=_("Put %s") % str(p))
            
            return HttpResponseRedirect(urlreverse("client_detail",server=request.server,kwargs={'id':id}))
    else:
        if client.followed.all():
            messages.error(request, _('User already exists.'))
            return HttpResponseRedirect(urlreverse("client_detail",server=request.server,kwargs={'id':id}))            
        form = FollowForm()
        
    return {'form': form, 'client': client}
Example #4
0
def direct(request):
    if request.method != 'POST':
        raise Http403
    pid = request.POST.get('playerid')
    next = request.POST.get('next')
    server = request.POST.get('server')
    
    if not has_server_perm(request.user, perm.VIEW_CLIENT, server):
        messages.error(request, _('You don\'t have enough permissions to search on that server.'))
        return HttpResponseRedirect(next)
    
    try:
        pid = int(pid)
    except:
        messages.error(request, _('You entered an invalid player id.'))
        return HttpResponseRedirect(next)
    try:
        player = Client.objects.using(server).get(id=pid)
    except Client.DoesNotExist:
        messages.warning(request, _('A player with id %d was not found.' % pid))
        return HttpResponseRedirect(next)
    return HttpResponseRedirect(urlreverse("client_detail",server=request.server,kwargs={'id':player.id}))
Example #5
0
                signals.add_penalty.send(sender=p, user=request.user,
                                                client=client,
                                                penalty=p,
                                                server=request.server)
            except Exception, e:
                logger.error(str(e))
            if notice:
                messages.success(request, _('Notice added successfully.'))
            else:
                messages.success(request, _('Penalty added successfully.'))
            return HttpResponse("{\"sucess\": true}", mimetype='application/json') 
            #return HttpResponseRedirect(urlreverse("client_detail", server=request.server, kwargs={'id':id}))
    else:
        form = frmObj()
    if notice:
        url = urlreverse("add_notice", server=request.server, kwargs={'id':id})
    else:
        url = urlreverse("add_penalty", server=request.server, kwargs={'id':id})
    return {'form': form, 'client': client, 'url': url}

@server_permission_required_with_403(perm.ADD_NOTES)
@render('b3portal/client/add_note.html')
def addnote(request, id):
    client = get_object_or_404(Client, id=id, using=request.server)
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            # penalty type in db is defined as enum.
            # so we treat a comment like an inactive notice with a special keyword
            p = Penalty(client=client,
                        type=PENALTY_TYPE_NOTICE,