示例#1
0
def search_detail(request):
    key = request.GET.get('key')
    return render(request, 'search.html', {
        'key': key,
        'head': tool.getOnlineUser(request),
        'title': '搜索:' + key
    })
示例#2
0
def post_complain(request):
    user_data = tool.getOnlineUser(request)
    post_brand = request.POST.get('post_brand')
    post_product = request.POST.get('post_product')
    post_title = request.POST.get('post_title')
    post_content = request.POST.get('post_content')

    post_img = request.FILES.getlist("post_img")
    names = tool.savePics(post_img)
    try:
        company = models.company.objects.get(company_name=post_brand)
    except models.company.DoesNotExist:
        company = models.company(company_name=post_brand,
                                 company_head='',
                                 company_introduce='')
        company.save()

    try:
        category = models.category.objects.get(id=1)
    except models.category.DoesNotExist:
        category = models.category(category_name='未分类')
        category.save()

    complain = models.complaint(
        brand_id=company,
        product=post_product,
        title=post_title,
        content=post_content,
        user_id=models.user.objects.get(id=user_data['user_id']),
        category_id=category,
        pic=names if names else '',
        reply_amount=0,
        status=0)
    complain.save()
    return HttpResponseRedirect('index')
示例#3
0
def complaint_cancel_collect(request):
    head = tool.getOnlineUser(request)
    post_id = request.GET.get('post_id')
    rows = models.collection_complaint.objects.filter(
        user_id=head['user_id'], collected_complaint_id=post_id)
    if len(rows) > 0:
        rows.delete()
        return JsonResponse({'result': True})
    else:
        return JsonResponse({'result': False})
示例#4
0
def person_info(request):
    head = tool.getOnlineUser(request)
    return render(
        request, 'person_info.html', {
            'title': head['user_name'] + '的个人主页',
            'head': head,
            'user_name': head['user_name'],
            'user_head': head['user_head'],
            'introduce': head['introduce'],
            'inPersonInfo': True
        })
示例#5
0
def person_edit(request):
    head = tool.getOnlineUser(request)
    return render(
        request, 'person_change.html', {
            'title': head['user_name'] + '的信息',
            'head': head,
            'user_name': head['user_name'],
            'user_head': head['user_head'],
            'email': head['email'] if head['email'] else '',
            'introduce': head['introduce'],
            'real_name': head['real_name'],
            'inPersonInfo': True
        })
示例#6
0
def complaint_detail(request):
    head = tool.getOnlineUser(request)

    post_id = request.GET.get('post_id')
    complaint = models.complaint.objects.get(id=post_id)
    user = complaint.user_id
    pics = tool.strToArr(complaint.pic)
    for i in range(0, len(pics)):
        pics[i] = tool.getOnePicPath(pics[i])
    isCollected = True
    try:
        if 'user_id' in head.keys():
            models.collection_complaint.objects.get(
                user_id=models.user.objects.get(id=head['user_id']),
                collected_complaint_id=models.complaint.objects.get(
                    id=post_id))
        else:
            isCollected = False
    except models.collection_complaint.DoesNotExist:
        isCollected = False
    return render(
        request, 'complaint.html', {
            'user_id':
            user.id,
            'user_name':
            user.username,
            'user_head':
            tool.getHeadPath(user.user_head),
            'title':
            complaint.title,
            'content':
            complaint.content,
            'time':
            tool.dbTimeFormat(complaint.create_time),
            'pics':
            pics,
            'head':
            head,
            'post_id':
            post_id,
            'amount':
            complaint.reply_amount,
            'like':
            models.collection_complaint.objects.filter(
                collected_complaint_id=post_id).count(),
            'isCollected':
            isCollected
        })
示例#7
0
def jury_page(request):
    jury_list = models.user.objects.filter(type=tool.JURY_USER)
    data = []
    for ju in jury_list:
        data.append({
            'jury_id': ju.id,
            'jury_name': ju.real_name,
            'jury_introduction': ju.introduce,
            'jury_head': tool.getHeadPath(ju.user_head),
        })
    pic_ad = tool.getOnePicPath(tool.getStaticData('pic_ad'))
    return render(
        request, "jury.html", {
            'head': tool.getOnlineUser(request),
            'title': '评审团',
            'list': data,
            'isJury': True,
            'pic_ad': pic_ad
        })
示例#8
0
def red_black_list(request):
    head = tool.getOnlineUser(request)

    red_rows = models.red_black.objects.filter(
        is_red=True).order_by('-score')[:10]
    black_rows = models.red_black.objects.filter(
        is_red=False).order_by('-score')[:10]
    red_list = []
    black_list = []
    num = 1
    for e in red_rows:
        red_list.append({
            'num':
            num,
            'company_name':
            e.company_id.company_name,
            'company_head':
            '../static/pic/' + e.company_id.company_head
        })
        num += 1
    num = 1
    for e in black_rows:
        black_list.append({
            'num':
            num,
            'company_name':
            e.company_id.company_name,
            'company_head':
            '../static/pic/' + e.company_id.company_head
        })
        num += 1

    return render(
        request, 'red_black.html', {
            'title': '企业信用评价表',
            'head': head,
            'red_list': red_list,
            'black_list': black_list,
            'isRedBlack': True
        })
示例#9
0
def index(request):
    pic1 = tool.getOnePicPath(tool.getStaticData('pic1'))
    pic2 = tool.getOnePicPath(tool.getStaticData('pic2'))
    pic3 = tool.getOnePicPath(tool.getStaticData('pic3'))
    pic1_title = tool.getStaticData('pic1_title')
    pic2_title = tool.getStaticData('pic2_title')
    pic3_title = tool.getStaticData('pic3_title')
    pic_ad = tool.getOnePicPath(tool.getStaticData('pic_ad'))

    return render(
        request, 'index.html', {
            'head': tool.getOnlineUser(request),
            'title': '主页',
            'isIndex': True,
            'pic_ad': pic_ad,
            'pic1': pic1,
            'pic2': pic2,
            'pic3': pic3,
            'pic1_title': pic1_title,
            'pic2_title': pic2_title,
            'pic3_title': pic3_title
        })
示例#10
0
def complaint_comment(request):
    head = tool.getOnlineUser(request)
    post_id = request.GET.get('post_id')
    content = request.GET.get('send_content')
    user = models.user.objects.get(id=head['user_id'])
    comment = models.comment(
        content=content,
        user_id=user,
        complaint_id=models.complaint.objects.get(id=post_id))
    comment.save()

    complaint = models.complaint.objects.get(id=post_id)
    complaint.reply_amount += 1
    if complaint.status == 0:
        if user.type == tool.JURY_USER:
            complaint.status = 2
        elif user.type == tool.COMPANY_USER:
            complaint.status = 3
        else:
            complaint.status = 1
    complaint.save()
    return HttpResponseRedirect('post_detail?post_id=' + post_id)
示例#11
0
def login_page(request):
    return render(request, 'login_page.html', {
        'head': tool.getOnlineUser(request),
        'title': '登录'
    })
示例#12
0
def register_page(request):
    return render(request, 'register_page.html', {
        'head': tool.getOnlineUser(request),
        'title': '注册'
    })
示例#13
0
def write_page(request):
    return render(request, 'blog_write.html',
                  {'head': tool.getOnlineUser(request)})