Пример #1
0
def userpanel_main(request):
    def getEvent(e):
        if e.type == Event.COMMENT_ON_EMPLOYER:
            return Event_CommentOnEmployer.objects.get(pk=e.pk)
        elif e.type == Event.COMMENT_ON_JOB:
            return Event_CommentOnOpportunity.objects.get(pk=e.pk)
        elif e.type == Event.FRIENDSHIP:
            return Event_FriendShip.objects.get(pk=e.pk)



    if request.userprofile.is_jobseeker():
        js = JobSeeker.objects.get(user = request.user)
        print(js)
        events = Event.objects.all().filter(initial_user = js)[:6] # event haye khodesh

        # friends = set([fs.jobSeeker2 for fs in js.requestedFriendShips.filter(status=FriendShip.ACCEPTED)])
        # friends.update(set(([fs.jobSeeker1 for fs in js.invitedFriendShips.filter(status=FriendShip.ACCEPTED)])))
        #
        #
        #
        #
        # events.update(set(list( Event.objects.all().filter()  )))
        print(events)
        events = [getEvent(e).summery() for e in events]
        print(list(events))
        return template(request, 'userpanel/jobseeker/main.html' , {'events' :events})
    elif request.userprofile.is_employer():
        return template(request, 'userpanel/employer/main.html')
Пример #2
0
def newJob(request):
    show_extra = False
    if request.method == "POST":
        form = JobForm(request.POST)
        if form.is_valid():
            job = form.save(False)
            job.user = request.userprofile
            job.save()
            show_extra = True
            return template(request, 'userpanel/employer/editJob.html', {'form' : form, 'show_extra': True, 'scroll_to_extra': True})
    else:
        form = JobForm()
    return template(request, 'userpanel/employer/editJob.html', {'form' : form, 'show_extra':show_extra})
Пример #3
0
def userpanel_friends(request):
    friends = [fs.jobSeeker2 for fs in JobSeeker.objects.get(user=request.user).requestedFriendShips.filter(status=FriendShip.ACCEPTED)]
    friends.extend([fs.jobSeeker1 for fs in JobSeeker.objects.get(user=request.user).invitedFriendShips.filter(status=FriendShip.ACCEPTED)])

    pending_friends = [fs.jobSeeker1 for fs in JobSeeker.objects.get(user=request.user).invitedFriendShips.filter(status=FriendShip.PENDING)]
    print('pending freinds: ')
    print(pending_friends)
    return template(request, 'userpanel/friends.html', {'friends': friends , 'pending_friends' : pending_friends})
Пример #4
0
def employer_jobs(request):
    user = request.userprofile
    jobs = JobOpportunity.objects.filter(user = user).order_by('-expireDate')
    items = []
    for j in jobs:
        pending = JobOffer.objects.filter(jobOpportunity = j, state = 2).count()
        accepted = JobOffer.objects.filter(jobOpportunity = j, state = 0).count()
        rejected = JobOffer.objects.filter(jobOpportunity = j, state = 1).count()
        items.append( {'job' : j, 'pending':pending, 'accepted' : accepted, 'rejected' : rejected} )
    return template(request, 'userpanel/employer/jobs.html', {'items' : items})
Пример #5
0
def editJob(request, jobid):
    job = JobOpportunity.objects.get(id = jobid)
    show_extra = False
    if request.method == "POST":
        form = JobForm(request.POST, instance=job)
        if form.is_valid():
            form.save()
            show_extra = True
            return userpanel_jobs(request)
    else:
        show_extra = True
        form = JobForm(instance = job)
    return template(request, 'userpanel/employer/editJob.html', {'form' : form, 'show_extra': show_extra})
Пример #6
0
def userpanel_offers(request):
    user = request.userprofile
    offers_by_jobseeker = JobOffer.objects.filter(jobOpportunity__user=user, mode=0).order_by('-date')
    offers_by_employer = JobOffer.objects.filter(jobOpportunity__user=user, mode=1).order_by('-date')
    return template(request, 'userpanel/employer/offers.html', {'offers_by_jobseeker' : offers_by_jobseeker, 'offers_by_employer' : offers_by_employer})
Пример #7
0
def userpanel_send_message(request):
    receiver = request.GET.get('to', None)
    return template(request, 'userpanel/inbox/send.html', {'receiver': receiver})
Пример #8
0
def userpanel_message(request, message_id):
    message = request.user.recieved_messages.get(pk=message_id)
    message.unread = False
    message.save()
    return template(request, 'userpanel/inbox/message.html', {'message': message})
Пример #9
0
def userpanel_inbox_list(request):
    messages = request.user.recieved_messages.all()
    print(request.user)
    print(messages)
    return template(request, 'userpanel/inbox/list.html', {'inbox': messages})
Пример #10
0
def userpanel_inbox(request):
    return template(request, 'userpanel/inbox/inbox.html')
Пример #11
0
def home(request):
    return template(request, 'home.html')
Пример #12
0
def jobPage(request, jobid):
    job = JobOpportunity.objects.get(id = jobid)
    skills = map(lambda x: x.name, job.opSkills.all())
    pages = list(job.pages.all())
    return template(request, 'jobs/jobsPage.html', {'job' : job, 'skills':skills, 'pages':pages})