Пример #1
0
def edit_details(request, pk, username):
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    if request.method == 'POST':
        #form = EditDetailsForm(request.POST, request.FILES, instance=request.user)
        form = EditDetailsForm(request.POST,
                               request.FILES,
                               instance=request.user.profile)

        if form.is_valid():
            user = form.save()

            #user.profile.dob = form.cleaned_data.get('dob')
            #user.profile.bio = form.cleaned_data.get('bio')
            #user.profile.skype = form.cleaned_data.get('skype')
            #user.profile.pic = request.FILES['pic']
            #user.profile.save()
            user.save()

            return redirect('view_profile', pk=pk, username=username)
    else:
        form = EditDetailsForm(instance=request.user.profile)

    context = {
        'form': form,
        'posts_home': posts_home,
        'today_pick': today_pick
    }

    return render(request, 'accounts/details_edit.html', context)
Пример #2
0
def view_profile(request, pk, username):
    user_profile = get_object_or_404(User, pk=pk)
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    interviews_all = Interview.objects.filter(
        Q(author=request.user)
        | Q(partner=request.user)).order_by('interview_date')
    posts_all = Post.objects.filter(
        author=request.user).order_by('created_date')
    comments_all = Comment.objects.filter(
        author=request.user).order_by('created_date')
    questions_all = Question.objects.filter(
        author=request.user).order_by('created_date')

    context = {
        'user_profile': user_profile,
        'interviews_all': interviews_all,
        'posts_all': posts_all,
        'comments_all': comments_all,
        'questions_all': questions_all,
        'posts_home': posts_home,
        'today_pick': today_pick,
    }

    return render(request, 'accounts/single_profile.html', context)
Пример #3
0
def industry_detail(request, pk, slug):
    today = datetime.date.today()
    posts = Post.objects.all()
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    industry = get_object_or_404(Industry, pk=pk)
    posts_latest = Post.objects.filter(
        industry=industry).order_by('-created_date')
    posts_popular = Post.objects.filter(industry=industry).order_by(
        'likes', 'comments')
    questions_latest = Question.objects.filter(
        industry=industry).order_by('-created_date')
    questions_popular = Question.objects.filter(
        industry=industry).order_by('likes')
    interview_latest = Interview.objects.filter(
        industry=industry,
        interview_date__gte=today).order_by('interview_date', 'interview_time')

    context = {
        'posts': posts,
        'posts_home': posts_home,
        'today_pick': today_pick,
        'industry': industry,
        'posts_latest': posts_latest,
        'posts_popular': posts_popular,
        'questions_latest': questions_latest,
        'questions_popular': questions_popular,
        'interview_latest': interview_latest
    }

    return render(request, 'search/category_detail.html', context)
Пример #4
0
def company_detail(request, pk, slug):
    today = datetime.date.today()
    posts = Post.objects.all()
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    company = get_object_or_404(Company, pk=pk)
    posts_latest = Post.objects.filter(
        company=company).order_by('-created_date')
    posts_popular = Post.objects.filter(company=company).order_by(
        'likes', 'comments')
    questions_latest = Question.objects.filter(
        company=company).order_by('-created_date')
    questions_popular = Question.objects.filter(
        company=company).order_by('likes')
    interview_latest = Interview.objects.filter(
        company=company,
        interview_date__gte=today).order_by('interview_date', 'interview_time')
    #posts_popular = Post.objects.annotate(number_of_comments=Count('comments', filter=Q(role=role)))

    context = {
        'posts': posts,
        'posts_home': posts_home,
        'today_pick': today_pick,
        'company': company,
        'posts_latest': posts_latest,
        'posts_popular': posts_popular,
        'questions_latest': questions_latest,
        'questions_popular': questions_popular,
        'interview_latest': interview_latest
    }

    return render(request, 'search/category_detail.html', context)
Пример #5
0
def interview_list(request):
    day0 = datetime.date.today()
    day1 = day0 + datetime.timedelta(days=1)
    day2 = day1 + datetime.timedelta(days=1)
    day3 = day2 + datetime.timedelta(days=1)
    day4 = day3 + datetime.timedelta(days=1)
    day5 = day4 + datetime.timedelta(days=1)
    day6 = day5 + datetime.timedelta(days=1)

    posts = Post.objects.all()
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    interview_day0 = Interview.objects.filter(
        interview_date__contains=day0).filter(
            accepted=False).order_by('interview_time')
    interview_day1 = Interview.objects.filter(
        interview_date__contains=day1).filter(
            accepted=False).order_by('interview_time')
    interview_day2 = Interview.objects.filter(
        interview_date__contains=day2).filter(
            accepted=False).order_by('interview_time')
    interview_day3 = Interview.objects.filter(
        interview_date__contains=day3).filter(
            accepted=False).order_by('interview_time')
    interview_day4 = Interview.objects.filter(
        interview_date__contains=day4).filter(
            accepted=False).order_by('interview_time')
    interview_day5 = Interview.objects.filter(
        interview_date__contains=day5).filter(
            accepted=False).order_by('interview_time')
    interview_day6 = Interview.objects.filter(
        interview_date__contains=day6).filter(
            accepted=False).order_by('interview_time')

    context = {
        'posts': posts,
        'posts_home': posts_home,
        'today_pick': today_pick,
        'day2': day2,
        'day3': day3,
        'day4': day4,
        'day5': day5,
        'day6': day6,
        'interview_day0': interview_day0,
        'interview_day1': interview_day1,
        'interview_day2': interview_day2,
        'interview_day3': interview_day3,
        'interview_day4': interview_day4,
        'interview_day5': interview_day5,
        'interview_day6': interview_day6
    }

    return render(request, 'interviews/interview_list.html', context)
Пример #6
0
def interview_accept(request, pk, slug):
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    interview = get_object_or_404(Interview, pk=pk)
    interview.partner = request.user
    interview.accept()
    context = {
        'interview': interview,
        'posts_home': posts_home,
        'today_pick': today_pick
    }

    return render(request, 'interviews/single_interview.html', context)
Пример #7
0
def post_detail(request, pk, slug):
    post = get_object_or_404(Post, pk=pk)
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    comments_all = Comment.objects.filter(post=post).order_by('created_date')

    context = {
        'post': post,
        'posts_home': posts_home,
        'today_pick': today_pick
    }

    return render(request, 'posts/single_post.html', context)
Пример #8
0
def category_list(request):
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    roles = Role.objects.all()
    companies = Company.objects.all()
    industries = Industry.objects.all()
    context = {
        'posts_home': posts_home,
        'today_pick': today_pick,
        'roles': roles,
        'companies': companies,
        'industries': industries
    }

    return render(request, 'search/category_list.html', context)
Пример #9
0
def feedback_new(request):
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    if request.method == "POST":
        form = FeedbackForm(request.POST)
        if form.is_valid():
            feedback = form.save(commit=False)
            feedback.author = request.user
            feedback.save()
            return redirect('home')
    else:
        form = FeedbackForm()
    context = {
        'form': form,
        'posts_home': posts_home,
        'today_pick': today_pick
    }

    return render(request, 'comms/contact.html', context)
Пример #10
0
def post_new(request):
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    if request.method == "POST":
        form = PostForm(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.author = request.user
            post.published_date = timezone.now()
            post.save()
            return redirect('post_detail', pk=post.pk, slug=post.slug)
    else:
        form = PostForm()
    context = {
        'form': form,
        'posts_home': posts_home,
        'today_pick': today_pick
    }
    return render(request, 'posts/post_edit.html', context)
Пример #11
0
def add_comment_to_post(request, pk, slug):
    post = get_object_or_404(Post, pk=pk)
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    if request.method == "POST":
        form = CommentForm(request.POST)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.post = post
            comment.author = request.user
            comment.save()
            return redirect('post_detail', pk=post.pk, slug=post.slug)
    else:
        form = CommentForm()
    context = {
        'form': form,
        'posts_home': posts_home,
        'today_pick': today_pick
    }

    return render(request, 'posts/add_comment_to_post.html', context)
Пример #12
0
def edit_profile(request, pk, username):
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            user = form.save()
            user.refresh_from_db()
            user.save()

            return redirect('view_profile', pk=pk, username=username)
    else:
        form = EditProfileForm(instance=request.user)

    context = {
        'form': form,
        'posts_home': posts_home,
        'today_pick': today_pick
    }

    return render(request, 'accounts/profile_edit.html', context)
Пример #13
0
def interview_new(request):
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    interviews = Interview.objects.all()
    if request.method == "POST":
        form = InterviewForm(request.POST)
        if form.is_valid():
            interview = form.save(commit=False)
            interview.author = request.user
            interview.save()
            return redirect('interview_detail',
                            pk=interview.pk,
                            slug=interview.slug)
    else:
        form = InterviewForm()
    context = {
        'form': form,
        'interviews': interviews,
        'posts_home': posts_home,
        'today_pick': today_pick
    }

    return render(request, 'interviews/interview_edit.html', context)
Пример #14
0
def signup(request):
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            user = form.save()
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=username, password=raw_password)
            login(request, user)
            user.profile.skype = form.cleaned_data.get('skype')
            user.save()
            return redirect('home')
    else:
        form = SignUpForm()

    context = {
        'form': form,
        'posts_home': posts_home,
        'today_pick': today_pick
    }

    return render(request, 'accounts/signup.html', context)
Пример #15
0
def home(request):
    posts_all = Post.objects.all().order_by('-created_date')
    posts_home = Post.objects.all().order_by('-created_date')[:5]
    today_pick = get_random_question()
    banking_posts = Post.objects.filter(
        industry__name__contains='Banking').order_by('-created_date')
    consulting_posts = Post.objects.filter(
        industry__name__contains='Consulting').order_by('-created_date')
    technology_posts = Post.objects.filter(
        industry__name__contains='Technology').order_by('-created_date')
    law_posts = Post.objects.filter(
        industry__name__contains='Law').order_by('-created_date')
    healthcare_posts = Post.objects.filter(
        industry__name__contains='Healthcare').order_by('-created_date')
    sport_posts = Post.objects.filter(
        industry__name__contains='Sport').order_by('-created_date')
    government_posts = Post.objects.filter(
        industry__name__contains='Government').order_by('-created_date')
    other_posts = Post.objects.filter(
        industry__name__contains='Other').order_by('-created_date')

    context = {
        'posts_all': posts_all,
        'posts_home': posts_home,
        'today_pick': today_pick,
        'banking_posts': banking_posts,
        'consulting_posts': consulting_posts,
        'technology_posts': technology_posts,
        'law_posts': law_posts,
        'healthcare_posts': healthcare_posts,
        'sport_posts': sport_posts,
        'government_posts': government_posts,
        'other_posts': other_posts
    }

    return render(request, 'posts/post_list.html', context)