Ejemplo n.º 1
0
def trialDetails(request, profileID):
    if not isFullMember(request.user):
        return render(
            request, 'error.html', {
                'title': '403 - Forbidden',
                'description': 'Only Full Members can access this page.'
            })

    trial_profile = UserProfile.objects.get(pk=profileID)
    if request.method == "POST":
        if request.POST.get('newComment', False):
            text = request.POST.get('commentbody')
            if text and text.strip():
                c = TrialComment()
                c.text = text.strip()
                c.author = request.user.userprofile
                c.date = datetime.utcnow()
                c.trial_member = trial_profile.user
                c.save()
        elif request.POST.get('yes', False):
            vote, created = TrialVote.objects.get_or_create(
                voter=request.user, trial_member=trial_profile.user)
            vote.approve = True
            vote.save()
        elif request.POST.get('no', False):
            vote, created = TrialVote.objects.get_or_create(
                voter=request.user, trial_member=trial_profile.user)
            vote.approve = False
            vote.save()
    ctx = {}
    ctx['trial_user'] = trial_profile
    ctx['user_comments'] = TrialComment.objects.filter(
        author=request.user.userprofile, trial_member=trial_profile.user)

    try:
        ctx['user_vote'] = TrialVote.objects.get(
            voter=request.user, trial_member=trial_profile.user)
    except TrialVote.DoesNotExist:
        pass

    if isRecruiter(request.user):
        ctx['admin'] = True
        ctx['yes_votes'] = TrialVote.objects.filter(
            trial_member=trial_profile.user, approve=True)
        ctx['no_votes'] = TrialVote.objects.filter(
            trial_member=trial_profile.user, approve=False)
        ctx['all_comments'] = TrialComment.objects.filter(
            trial_member=trial_profile.user)
    return render(request, 'trialdetails.html', ctx)
Ejemplo n.º 2
0
def applications(request):
    if not isRecruiter(request.user):
        return render(request, 'error.html', {
            'title': '403 - Forbidden',
            'description': 'You are not a recruiter.'
        })
    apps = Application.objects.all()
    unp = apps.filter(
        status=Application.UNPROCESSED).order_by('applicationDate')
    hld = apps.filter(status=Application.HOLD).order_by('-applicationDate')
    dnd = apps.filter(status=Application.DENIED).order_by('-applicationDate')
    yes = apps.filter(status=Application.ACCEPTED).order_by('-applicationDate')

    c = {"unprocessed": unp, "hold": hld, "denied": dnd, "accepted": yes}
    return render(request, "applications.html", c)
Ejemplo n.º 3
0
def checkPlan(request, characterID):
    try:
        c = Character.objects.get(charID=characterID)
    except:
        c = False

    if c:
        if not (isRecruiter(request.user) or c.profile.user == request.user):
            return HttpResponseForbidden(
                '<h1>You do not have the permissions to view this character\'s skillplans</h1>'
            )

        return render(request, 'tags/skillplans.html', {
            'result': compareSkillplans(c),
            'character': c
        })
Ejemplo n.º 4
0
def newApplication(request):
    if not isRecruiter(request.user):
        return render(request, 'error.html', {
            'title': '403 - Forbidden',
            'description': 'You are not a recruiter.'
        })
    sample = string.lowercase + string.digits
    token = ''.join(random.sample(sample, 5))

    app = Application(token=token)
    app.save()
    c = Comment(app=app,
                author=request.user.userprofile,
                date=datetime.utcnow(),
                text="Generated the Token",
                auto_generated=True)
    c.save()
    return HttpResponse(
        request.build_absolute_uri(
            reverse('applications:apply', kwargs={'token': token})))
Ejemplo n.º 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)