Пример #1
0
def ticketSubmit(request):
    if not isDropbears(request.user):
        return render(request, 'error.html', {
            'title': '403 - Forbidden',
            'description': 'You are not a member.'
        })
    c = {}
    if request.method == "POST":
        error = False
        new = Ticket()
        anonymous = request.POST.get("anonymous") == "on"
        new.author = None if anonymous else request.user.userprofile

        new.title = request.POST.get('title', '')
        new.text = request.POST.get('text', '')
        new.category = int(request.POST.get('category', 0))
        sample = string.lowercase + string.digits
        new.token = ''.join(random.sample(sample, 8))
        new.save()
        c["message"] = "Successfully added <a href='" + reverse(
            'helpdesk:viewticket', kwargs={"token": new.token}
        ) + "'>Ticket #" + str(
            new.id
        ) + " \"" + new.title + "\"</a>. If you chose to submit anonymously, save this link as it's your only way to access it."

        director = Group.objects.filter(name="Director").first()
        note = Notification(cssClass="info")
        if anonymous:
            note.content = "Someone added a new Ticket: <a href='" + reverse(
                'helpdesk:viewticket',
                kwargs={"token": new.token}) + "'>\"" + new.title + "\"</a>"
        else:
            note.content = "<a href='" + reverse(
                'core:playerProfile',
                kwargs={"profileName": slugify(request.user.userprofile)}
            ) + "'>" + unicode(
                new.author) + "</a> added a new Ticket: <a href='" + reverse(
                    'helpdesk:viewticket', kwargs={
                        "token": new.token
                    }) + "'>\"" + new.title + "\"</a>"
        note.save()
        note.targetGroup.add(director)

        c["error"] = error

    c["users"] = Group.objects.filter(name="Director").first().user_set.all()

    return render(request, "ticketsubmit.html", c)
Пример #2
0
def apply_common(request, app):
    if request.method == "POST":
        count = 1
        answers = []
        for q in appmodule.questions:
            answer = Answer(app=app,
                            question=q["text"],
                            text=request.POST.get("q" + unicode(count)))
            answers.append(answer)
            count += 1
        app.status = 1
        app.timezone = request.POST.get('tz')
        app.applicantProfile = request.user.userprofile
        app.applicationDate = datetime.utcnow()
        app.save()
        recruiter = Group.objects.filter(name="Recruiter").first()
        note = Notification(cssClass="success")
        note.content = "New Application from <a href='" + reverse(
            'applications:viewapp', kwargs={
                "app": app.token
            }) + "'>" + unicode(request.user.userprofile) + "</a>."
        note.save()
        note.targetGroup.add(recruiter)

        Answer.objects.bulk_create(answers)

        return redirect("applications:mystatus")

    else:
        return render(request, "apply.html",
                      {"questions": appmodule.questions})
Пример #3
0
def submit(request):
    if not isDropbears(request.user):
        return render(request, 'error.html', {
            'title': '403 - Forbidden',
            'description': 'You are not a member.'
        })
    c = {}
    if request.method == "POST":
        error = False
        new = SRPRequest()
        new.owner = request.user.userprofile

        link = request.POST.get('link', False)
        if link:
            new.killID = link.split("/")[-2]
            if SRPRequest.objects.filter(killID=new.killID).exists():
                error = True
                return render(request, "submit.html", c)
            shipID, shipName, pilot, corp, value = getKillInformation(
                new.killID)
        if not link or not shipID:
            error = True
        else:
            new.value = int(float(value))
            new.shipID = shipID
            new.fc = request.POST.get('fc', '')
            new.aar = request.POST.get('aar', '')
            new.learned = request.POST.get('learned', '')
            new.suggestions = request.POST.get('suggestions', '')
            new.pilot = pilot
            new.corp = corp
            new.ship = shipName
            new.save()
            c["message"] = "Successfully added kill #" + new.killID
            finance = Group.objects.filter(name="Finance").first()
            note = Notification(cssClass="info")
            note.content = "New <a href='" + reverse(
                'srp:viewsrp', kwargs={"killID": new.killID}
            ) + "'>SRP request for a " + shipName + "</a> added by <a href='" + reverse(
                'core:playerProfile',
                kwargs={"profileName": slugify(request.user.userprofile)
                        }) + "'>" + unicode(request.user.userprofile) + "</a>."
            note.save()
            note.targetGroup.add(finance)

        c["error"] = error

    return render(request, "submit.html", c)
Пример #4
0
def viewsrp(request, killID):
    kill = SRPRequest.objects.get(killID=killID)
    f = isFinance(request.user)
    if not (f or request.user.userprofile == kill.owner):
        return render(request, 'error.html', {
            'title': '403 - Forbidden',
            'description': 'You are not a member.'
        })

    if request.method == "POST":
        if request.POST.get('newComment', False):
            c = SRPComment()
            c.text = request.POST.get('commentbody')
            c.author = request.user.userprofile
            c.date = datetime.utcnow()
            c.request = kill
            c.save()
            finance = Group.objects.filter(name="Finance").first()
            note = Notification(cssClass="info")
            note.content = "<a href='" + reverse(
                'core:playerProfile',
                kwargs={"profileName": slugify(
                    request.user.userprofile)}) + "'>" + unicode(
                        c.author) + "</a> commented on <a href='" + reverse(
                            'srp:viewsrp',
                            kwargs={"killID": kill.killID}) + "'>" + unicode(
                                kill.owner
                            ) + "'s SRP Request for a " + kill.ship + "</a>"
            note.save()
            note.targetGroup.add(finance)
            note.targetUsers.add(kill.owner.user)
        elif request.POST.get('approve', False) and kill.status != 1 and f:
            kill.status = 1
            kill.approver = request.user.userprofile
            n = Notification(
                cssClass='success',
                content='Your <a href="' + reverse("srp:srplist") +
                '">SRP request</a> for a ' + kill.ship + ' has been accepted.')
            n.save()
            n.targetUsers.add(kill.owner.user)
        elif request.POST.get('deny', False) and kill.status != 2 and f:
            kill.status = 2
            kill.approver = request.user.userprofile
            n = Notification(
                cssClass='danger',
                content='Your <a href="' + reverse("srp:srplist") +
                '">SRP request</a> for a ' + kill.ship + ' has been denied.')
            n.save()
            n.targetUsers.add(kill.owner.user)
        elif request.POST.get('pending', False) and kill.status != 0 and f:
            kill.status = 0
            kill.approver = None
            n = Notification(
                cssClass='warning',
                content='Your <a href="' + reverse("srp:srplist") +
                '">SRP request</a> for a ' + kill.ship + ' has been reset.')
            n.save()
            n.targetUsers.add(kill.owner.user)
        kill.save()

    if not Character.objects.filter(charName=kill.pilot).exists():
        apiwarning = True
    else:
        apiwarning = False

    if not kill:
        return render(
            request, 'error.html', {
                'title': '404 - Not Found',
                'description': 'There is no kill with that ID in the database.'
            })
    c = {"kill": kill, "apiwarning": apiwarning, "admin": f}
    return render(request, "srpdetails.html", c)
Пример #5
0
def application(request, app):
    if not isRecruiter(request.user):
        return render(request, 'error.html', {
            'title': '403 - Forbidden',
            'description': 'You are not a recruiter.'
        })

    hr = isHR(request.user)
    app = Application.objects.filter(token=app).first()

    if app.status == Application.ACCEPTED and not hr:
        return render(
            request, 'error.html', {
                'title':
                '403 - Forbidden',
                'description':
                'For privacy reasons, only HR officers can view accepted applications.'
            })

    if request.method == "POST":
        if request.POST.get('newComment'):
            c = Comment()
            c.text = request.POST.get('commentbody')
            c.author = request.user.userprofile
            c.date = datetime.utcnow()
            c.auto_generated = False
            c.app = app
            c.save()
            recruiter = Group.objects.filter(name="Recruiter").first()
            note = Notification(cssClass="info")
            note.content = "<a href='" + reverse(
                'core:playerProfile',
                kwargs={"profileName": slugify(
                    request.user.userprofile)}) + "'>" + unicode(
                        c.author) + "</a> commented on <a href='" + reverse(
                            'applications:viewapp',
                            kwargs={"app": app.token}) + "'>" + unicode(
                                app.applicantProfile) + "'s Application</a>."
            note.save()
            note.targetGroup.add(recruiter)
        if request.POST.get('updatestatus'):
            newStatus = int(request.POST.get('status'))
            newTag = int(request.POST.get('tag'))
            if app.status != newStatus and app.STATUS_CHOICES[newStatus]:
                c = Comment(auto_generated=True,
                            date=datetime.utcnow(),
                            app=app,
                            author=request.user.userprofile)
                oldstatus = app.get_status_display()
                app.status = newStatus
                c.text = "changed Status from '" + oldstatus + "' to '" + app.get_status_display(
                ) + "'"
                c.save()
                if newStatus == Application.ACCEPTED:
                    Group.objects.get(name='Member').user_set.add(
                        app.applicantProfile.user)
                else:
                    Group.objects.get(name='Member').user_set.remove(
                        app.applicantProfile.user)
            if app.tag != newTag and app.TAG_CHOICES[newTag]:
                c = Comment(auto_generated=True,
                            date=datetime.utcnow(),
                            app=app,
                            author=request.user.userprofile)
                oldtag = app.get_tag_display()
                app.tag = newTag
                c.text = "changed Tag from '" + oldtag + "' to '" + app.get_tag_display(
                ) + "'"
                c.save()
            app.save()

    profile = app.applicantProfile
    keys = profile.apikey_set.all()
    characters = profile.character_set.all()
    answers = app.answer_set.all()

    r = getFlyable(profile)
    c = {
        "app": app,
        "profile": profile,
        "keys": keys,
        "answers": answers,
        "ships": r,
        "skills": compareSkillplans(profile.mainChar)
    }
    return render(request, "application.html", c)
Пример #6
0
def viewTicket(request, token):
    ticket = Ticket.objects.get(token=token)
    f = isDirector(request.user)
    if not (f or not ticket.author
            or request.user.userprofile == ticket.author):
        return render(
            request, 'error.html', {
                'title': '403 - Forbidden',
                'description': 'You do not have permission to view this page.'
            })

    if request.method == "POST":

        director = Group.objects.filter(name="Director").first()
        oldstatus = ticket.get_status_display()

        if request.POST.get('newComment', False):

            c = Comment()
            c.text = request.POST.get('commentbody')
            c.author = request.user.userprofile
            c.date = datetime.utcnow()
            c.ticket = ticket
            c.private = request.POST.get('private') == "on"
            c.save()

            note = Notification(cssClass="info")
            note.content = "<a href='" + reverse(
                'core:playerProfile',
                kwargs={
                    "profileName": slugify(request.user.userprofile)
                }) + "'>" + unicode(
                    c.author) + "</a> commented on <a href='" + reverse(
                        'helpdesk:viewticket',
                        kwargs={"token": ticket.token}) + "'>Ticket #" + str(
                            ticket.id) + " \"" + ticket.title + "\"</a>"
            note.save()
            note.targetGroup.add(director)
            if ticket.author and not c.private:
                note.targetUsers.add(ticket.author.user)

        elif request.POST.get('inprogress',
                              False) and ticket.status != 1 and f:
            ticket.status = 1
            n = Notification(
                cssClass='success',
                content="<a href='" + reverse('helpdesk:viewticket',
                                              kwargs={"token": ticket.token}) +
                "'>Ticket #" + str(ticket.id) + " \"" + ticket.title +
                "\"</a> has been set to \"In Progress\" by <a href='" +
                reverse('core:playerProfile',
                        kwargs={
                            "profileName": slugify(request.user.userprofile)
                        }) + "'>" + unicode(request.user.userprofile) + "</a>")
            n.save()
            if ticket.author:
                n.targetUsers.add(ticket.author.user)
            n.targetGroup.add(director)

        elif request.POST.get('resolved', False) and ticket.status != 2 and f:
            ticket.status = 2
            n = Notification(
                cssClass='success',
                content="<a href='" + reverse('helpdesk:viewticket',
                                              kwargs={"token": ticket.token}) +
                "'>Ticket #" + str(ticket.id) + " \"" + ticket.title +
                "\"</a> has been set to \"Resolved\" by <a href='" + reverse(
                    'core:playerProfile',
                    kwargs={"profileName": slugify(request.user.userprofile)})
                + "'>" + unicode(request.user.userprofile) + "</a>")
            n.save()
            if ticket.author:
                n.targetUsers.add(ticket.author.user)
            n.targetGroup.add(director)

        elif request.POST.get('new', False) and ticket.status != 0 and f:
            ticket.status = 0
            n = Notification(
                cssClass='warning',
                content="<a href='" + reverse('helpdesk:viewticket',
                                              kwargs={"token": ticket.token}) +
                "'>Ticket #" + str(ticket.id) + " \"" + ticket.title +
                "\"</a> has been set to \"New\" by <a href='" + reverse(
                    'core:playerProfile',
                    kwargs={"profileName": slugify(request.user.userprofile)})
                + "'>" + unicode(request.user.userprofile) + "</a>")
            n.save()
            if ticket.author:
                n.targetUsers.add(ticket.author.user)
            n.targetGroup.add(director)

        if oldstatus != ticket.get_status_display():
            c = Comment(auto_generated=True)
            c.text = "changed Satus from \"" + oldstatus + "\" to \"" + ticket.get_status_display(
            ) + "\""
            c.author = request.user.userprofile
            c.date = datetime.utcnow()
            c.ticket = ticket
            c.private = False
            c.save()

        ticket.save()

    if not ticket:
        return render(request, 'error.html', {
            'title': '404 - Not Found',
            'description': 'Ticket not found.'
        })

    comments = Comment.objects.filter(
        ticket=ticket) if f else Comment.objects.filter(ticket=ticket).filter(
            private=False)

    c = {"ticket": ticket, "admin": f, "comments": comments}
    return render(request, "ticketdetails.html", c)