示例#1
0
def company_jobs(request):
    login_user = request.user.username
    published_jobs = JobInformation.objects.filter(
        publisher__contact__username=login_user).annotate(
            num=Count('fk_apply'))
    job_list, page_list = pagination(request, published_jobs)
    return job_render(request, 'company_jobs.html', {
        'job_list': job_list,
        'page_list': page_list
    })
示例#2
0
def applicant_apply_history(request):
    login_user = request.user.username
    apply_history = JobInformation.objects.filter(
        fk_apply__candidates__username=login_user).values(
            'id', 'job_type', 'publisher__id', 'publisher__name',
            'fk_apply__date_created')
    job_list, page_list = pagination(request, apply_history)
    return job_render(request, 'applicant_apply.html', {
        'job_list': job_list,
        'page_list': page_list,
    })
示例#3
0
文件: views.py 项目: ptoeia/job
def company_jobs(request):
    login_user = request.user.username
    published_jobs = JobInformation.objects.filter(
                                        publisher__contact__username=login_user
                                        ).annotate(num=Count('fk_apply')
                                        )
    job_list, page_list = pagination(request, published_jobs)
    return job_render(request,
                         'company_jobs.html', {
                         'job_list':job_list, 'page_list': page_list
                                })
示例#4
0
文件: views.py 项目: ptoeia/job
def applicant_apply_history(request):
    login_user = request.user.username
    apply_history = JobInformation.objects.filter(
                                                   fk_apply__candidates__username=login_user).values(
                                                   'id', 'job_type', 'publisher__id',
                                                   'publisher__name', 'fk_apply__date_created'
                                                   )
    job_list, page_list = pagination(request, apply_history)
    return job_render(request, 'applicant_apply.html', {
                                                         'job_list': job_list,
                                                         'page_list': page_list,
                                                          })
示例#5
0
文件: views.py 项目: ptoeia/job
def job_information(request):#首页index
    user = request.user.username
    session_key = request.session.get('sessionid')
    keyword = request.GET.get('q', '')
    if 'q' in request.GET:
        query = request.GET['q']
        qset = (
                 Q(job_type__icontains=query)|
                 Q(job_description__icontains=query)|
                 Q(publisher__name__icontains=query)
                )
        jobs = JobInformation.objects.filter(qset).order_by("-date_created")
        job_list, page_list = pagination(request, jobs)#分页函数
    else:
        try:
            jobs = JobInformation.objects.all().order_by("-date_created")
            job_list, page_list = pagination(request, jobs)
        except jobs.DoesNotExist:
            raise Http404("job dose not exist")
    return job_render(request, 'index.html', {'job_list': job_list,'page_list':page_list,
                                             'session_key':session_key,'keyword':keyword,})
示例#6
0
    def get_context_data(self, **kwargs):
        page_limit = 5
        context = super(TagDetails, self).get_context_data(**kwargs)
        tab = self.request.GET.get('tab')
        if not tab:
            tab = 'Summary'
        page = self.request.GET.get('page')
        # lists that are paginated. 
        wiki_list = self.object.pages.order_by('-bookmark_count')
        question_list = self.object.questions()
        discussion_list = self.object.discussions()
        blog_list = self.object.blogs()
        usertag_list = self.object.usertags.filter(answer_count__gt = 0).order_by('-answer_count')
        # get the count 
        wiki_list_count = wiki_list.count()
        question_list_count = question_list.count()
        discussion_list_count = discussion_list.count()
        blog_list_count = blog_list.count()
        usertag_list_count = usertag_list.count()
        
        # paginate the list 
        wiki_list = pagination(wiki_list,page,page_limit)
        question_list = pagination(question_list,page,page_limit)
        discussion_list = pagination(discussion_list,page,page_limit)
        blog_list = pagination(blog_list,page,page_limit)
        usertag_list = pagination(usertag_list,page,page_limit)
        # 
        
        
        context['tab'] = tab
        context['tag_wiki'] = self.object.wiki_page
        context['wiki_list'] = wiki_list#self.object.pages.all()
        context['question_list'] = question_list #self.object.questions()
        context['discussion_list'] = discussion_list #self.object.discussions()
        context['blog_list'] = blog_list #self.object.blogs()
        context['usertag_list'] = usertag_list #self.object.usertags.filter(answer_count__gt = 0).order_by('-answer_count')
        # list count 
        context['wiki_list_count'] = wiki_list_count 
        context['question_list_count'] = question_list_count 
        context['discussion_list_count'] = discussion_list_count 
        context['blog_list_count'] = blog_list_count 
        context['usertag_list_count'] = usertag_list_count 
        # for workflow tags: 
        #if self.object.get_categories_display == "workflow":
        software_list = self.object.pages.filter(software__isnull=False)
        software_list_count = software_list.count()
        software_list = pagination(software_list, page, page_limit)
        context['software_list'] = software_list
        context['software_list_count'] = software_list_count
        # pagination object. 
        tab_list_dict = {'Wiki':wiki_list,'Software':software_list, 'Questions':question_list, 'Discussions':discussion_list, 'Blogs':blog_list, 'Contributors':usertag_list, 'Summary':False,'':False}
        page_obj = tab_list_dict[tab]
        context['page_obj'] = page_obj 

        if page_obj != False:
            context['is_paginated']=True
        return context
示例#7
0
def job_information(request):  #首页index
    user = request.user.username
    session_key = request.session.get('sessionid')
    keyword = request.GET.get('q', '')
    if 'q' in request.GET:
        query = request.GET['q']
        qset = (Q(job_type__icontains=query)
                | Q(job_description__icontains=query)
                | Q(publisher__name__icontains=query))
        jobs = JobInformation.objects.filter(qset).order_by("-date_created")
        job_list, page_list = pagination(request, jobs)  #分页函数
    else:
        try:
            jobs = JobInformation.objects.all().order_by("-date_created")
            job_list, page_list = pagination(request, jobs)
        except jobs.DoesNotExist:
            raise Http404("job dose not exist")
    return job_render(
        request, 'index.html', {
            'job_list': job_list,
            'page_list': page_list,
            'session_key': session_key,
            'keyword': keyword,
        })
示例#8
0
def get_all_statistics():
    page = request.args.get('page', 1, type=int) or '1'
    per_page = request.args.get('per_page', type=int) or '20'
    statistics = Statistics.query.all()
    pagination_lit = pagination(statistics, int(page), int(per_page),
                                "api.get_all_statistics")
    current = pagination_lit[0]
    next_page = pagination_lit[1][0]
    last_page = pagination_lit[1][1]
    return json.dumps([s.to_json() for s in current],
                      ensure_ascii=False,
                      indent=1), 200, {
                          'link': '<%s>; rel="next", <%s>; rel="last"' %
                          (next_page, last_page)
                      }
示例#9
0
 def get(self, id=None):
     """查
     根据db主键id查询对应记录
     ---
     tags:
       - db.demo
     parameters:
       - name: id
         in: path
         required: false
         type: integer
         description: URL endswith id will query singel record,
             no id query all records.
     responses:
       200:
         description: 接口返回JSON数据
         schema:
           $ref: '#/definitions/response'
         examples:
           成功: {"code": 0, "msg": "SUCCESS", "data": null}
           失败: {"code": -1, "msg": "FAILURE", "data": null}
           参数错误: {"code": 400, "msg": "PARAMS ERROR", "data": null}
           资源不存在: {"code": 404, "msg": "ENTITY NOT FOUND", "data": null}
           服务器错误: {"code": 500, "msg": "INTERNAL SERVER ERROR",
                        "data": null}
     """
     if id is None:
         page_num = int(request.values.get('page_num', 1))
         page_size = int(request.values.get('page_size', 10))
         order_by = request.values.get('order_by', 'id')
         order_type = request.values.get('order_type', 'desc')
         send_status = request.values.get('send_status')
         items = handlers.get_message(order_by=order_by,
                                      order_type=order_type,
                                      page_num=page_num,
                                      page_size=page_size,
                                      send_status=send_status)
         items_count = handlers.get_message_count(send_status)
         data = {
             'items': items,
             'pagination': pagination(items_count, page_num, page_size)
         }
     else:
         data = handlers.get_message(id)
     return response(data)
示例#10
0
def search(request):
#    template_name = "search.html"
    PAGE_LIMIT = 25
    field = request.GET.get('search_field')
    text = request.GET.get('search_text')
    new_search = Search(text=text)
    new_search.save()
    
    if field == "All":
        wiki = Page.objects.filter(title__icontains = text)
        posts = MainPost.objects.filter(title__icontains = text)
        tools = Tool.objects.filter(name__icontains = text)
        return render(request, "utils/search_results_all.html", {"wiki_list":wiki,"post_list":posts,"tool_list":tools,"search_text":text})
    else:
        page = request.GET.get('page')
        if field == "Wiki":
            list = Page.objects.filter(title__icontains = text)
        elif field == "Post":
            list = MainPost.objects.filter(title__icontains = text)
        elif field == "Tool":
            list = Tool.objects.filter(name__icontains = text)
            
        list = pagination(list, page, PAGE_LIMIT)
        return render(request, "utils/search_results_list.html", {'list':list, 'search_text':text,'search_field':field})
示例#11
0
    def get_context_data(self, **kwargs):
        page_limit = 20
        context = super(ProfileView, self).get_context_data(**kwargs)
        tab = self.request.GET.get('tab')
        if not tab: 
            tab = "Summary" 
        mark = self.request.GET.get('mark')
        if not mark:
            mark = 'posts'
        page = self.request.GET.get('page')
        # 1. questions 
        questions = self.object.user.questions()
        # 2. answers
        answers = self.object.user.replypost_set.all()
        # 3. discussions
        discussions = self.object.user.discussions()
        # 4. blogs 
        blogs = self.object.user.blogs()
        # 5. bookmarks
        bookmarks = self.object.user.bookmarks.all()
        # bookmarked posts
        post_bookmarks = bookmarks.filter(content_type=ContentType.objects.get_for_model(MainPost))
        id = post_bookmarks.values_list('object_id',flat=True)
        bookmark_posts = MainPost.objects.filter(id__in = id)
        # bookmarked wiki
        wiki_bookmarks = bookmarks.filter(content_type=ContentType.objects.get_for_model(Page))
        id = wiki_bookmarks.values_list('object_id',flat=True)
        bookmark_wiki = Page.objects.filter(id__in = id)
        bookmark_software = Tool.objects.filter(page__id__in = id)
        # tags that the author contributed to 
        usertags = UserTag.objects.filter(user = self.object.user).order_by('-answer_count')
        # wikis that authors contribute to. 
        userpages = UserPage.objects.filter(user = self.object.user, edits__gt = 0).order_by('-added')
        # list count 
        question_count = questions.count()
        answer_count = answers.count()
        discussion_count = discussions.count()
        blog_count = blogs.count()
        bookmark_count = bookmarks.count()+bookmark_software.count()
        bookmark_wiki_count = bookmark_wiki.count()
        bookmark_post_count = bookmark_posts.count()
        bookmark_software_count = bookmark_software.count()
        usertag_count = usertags.count()
        userpage_count = userpages.count()
        # paginate the list 
        question_list = pagination(questions, page, page_limit)
        answer_list = pagination(answers, page, page_limit)
        discussion_list = pagination(discussions, page, page_limit)
        blog_list = pagination(blogs, page, page_limit)
        bookmark_post_list = pagination(bookmark_posts, page, page_limit)
        bookmark_wiki_list = pagination(bookmark_wiki, page, page_limit)
        bookmark_software_list = pagination(bookmark_software, page, page_limit)
        usertag_list = pagination(usertags, page, page_limit)
        userpage_list = pagination(userpages, page, page_limit)
        tab_list_dict = {'Questions':question_list, 'Answers':answer_list,'Discussions':discussion_list, 'Blogs':blog_list, 'Bookmarks':{'wiki':bookmark_wiki,'posts':bookmark_posts, 'software':bookmark_software}, 'Tags':usertag_list,'Wiki':userpage_list, 'Summary':False,  '':False}
        page_obj = tab_list_dict[tab]
        # if page obj is one of the bookmark. 
        if tab == 'Bookmarks':
            page_obj = page_obj[mark]
        # adding the list to the context. 
        context['tab'] = tab
        context['mark'] = mark
        context['page_obj'] = page_obj
        context['questions'] = question_list
        context['answers'] = answer_list
        context['discussions'] = discussion_list
        context['blogs'] = blog_list 
        context['bookmark_posts'] = bookmark_post_list
        context['bookmark_wiki'] = bookmark_wiki_list
        context['bookmark_software'] = bookmark_software_list
        context['usertag_list'] = usertag_list
        context['userpage_list'] = userpage_list
        # list count
        context['question_count'] = question_count
        context['answer_count'] = answer_count
        context['discussion_count'] = discussion_count
        context['blog_count'] = blog_count
        context['bookmark_count'] = bookmark_count
        context['bookmark_wiki_count'] = bookmark_wiki_count
        context['bookmark_post_count'] = bookmark_post_count
        context['bookmark_software_count'] = bookmark_software_count
        context['usertag_count'] = usertag_count
        context['userpage_count'] = userpage_count
        if page_obj != False:
            context['is_paginated']=True
 
        return context
示例#12
0
    def get_context_data(self, **kwargs):
        page_limit = 20
        context = super(ProfileView, self).get_context_data(**kwargs)
        tab = self.request.GET.get('tab')
        if not tab:
            tab = "Summary"
        mark = self.request.GET.get('mark')
        if not mark:
            mark = 'posts'
        page = self.request.GET.get('page')
        # 1. questions
        questions = self.object.user.questions()
        # 2. answers
        answers = self.object.user.replypost_set.all()
        # 3. discussions
        discussions = self.object.user.discussions()
        # 4. blogs
        blogs = self.object.user.blogs()
        # 5. bookmarks
        bookmarks = self.object.user.bookmarks.all()
        # bookmarked posts
        post_bookmarks = bookmarks.filter(
            content_type=ContentType.objects.get_for_model(MainPost))
        id = post_bookmarks.values_list('object_id', flat=True)
        bookmark_posts = MainPost.objects.filter(id__in=id)
        # bookmarked wiki
        wiki_bookmarks = bookmarks.filter(
            content_type=ContentType.objects.get_for_model(Page))
        id = wiki_bookmarks.values_list('object_id', flat=True)
        bookmark_wiki = Page.objects.filter(id__in=id)
        bookmark_software = Tool.objects.filter(page__id__in=id)
        # tags that the author contributed to
        usertags = UserTag.objects.filter(
            user=self.object.user).order_by('-answer_count')
        # wikis that authors contribute to.
        userpages = UserPage.objects.filter(user=self.object.user,
                                            edits__gt=0).order_by('-added')
        # list count
        question_count = questions.count()
        answer_count = answers.count()
        discussion_count = discussions.count()
        blog_count = blogs.count()
        bookmark_count = bookmarks.count() + bookmark_software.count()
        bookmark_wiki_count = bookmark_wiki.count()
        bookmark_post_count = bookmark_posts.count()
        bookmark_software_count = bookmark_software.count()
        usertag_count = usertags.count()
        userpage_count = userpages.count()
        # paginate the list
        question_list = pagination(questions, page, page_limit)
        answer_list = pagination(answers, page, page_limit)
        discussion_list = pagination(discussions, page, page_limit)
        blog_list = pagination(blogs, page, page_limit)
        bookmark_post_list = pagination(bookmark_posts, page, page_limit)
        bookmark_wiki_list = pagination(bookmark_wiki, page, page_limit)
        bookmark_software_list = pagination(bookmark_software, page,
                                            page_limit)
        usertag_list = pagination(usertags, page, page_limit)
        userpage_list = pagination(userpages, page, page_limit)
        tab_list_dict = {
            'Questions': question_list,
            'Answers': answer_list,
            'Discussions': discussion_list,
            'Blogs': blog_list,
            'Bookmarks': {
                'wiki': bookmark_wiki,
                'posts': bookmark_posts,
                'software': bookmark_software
            },
            'Tags': usertag_list,
            'Wiki': userpage_list,
            'Summary': False,
            '': False
        }
        page_obj = tab_list_dict[tab]
        # if page obj is one of the bookmark.
        if tab == 'Bookmarks':
            page_obj = page_obj[mark]
        # adding the list to the context.
        context['tab'] = tab
        context['mark'] = mark
        context['page_obj'] = page_obj
        context['questions'] = question_list
        context['answers'] = answer_list
        context['discussions'] = discussion_list
        context['blogs'] = blog_list
        context['bookmark_posts'] = bookmark_post_list
        context['bookmark_wiki'] = bookmark_wiki_list
        context['bookmark_software'] = bookmark_software_list
        context['usertag_list'] = usertag_list
        context['userpage_list'] = userpage_list
        # list count
        context['question_count'] = question_count
        context['answer_count'] = answer_count
        context['discussion_count'] = discussion_count
        context['blog_count'] = blog_count
        context['bookmark_count'] = bookmark_count
        context['bookmark_wiki_count'] = bookmark_wiki_count
        context['bookmark_post_count'] = bookmark_post_count
        context['bookmark_software_count'] = bookmark_software_count
        context['usertag_count'] = usertag_count
        context['userpage_count'] = userpage_count
        if page_obj != False:
            context['is_paginated'] = True

        return context