Exemple #1
0
def search_guest(request):
    user_id = request.session.get('user_id', '')
    if not get_user(user_id):
        request.session['login_from'] = '/base/project/'
        return render(request, 'user/login_action.html')
    else:
        username = request.session.get('user', '')
        search_guest = request.GET.get('name', '')
        guest_list = Guest.objects.filter(
            Q(phone__contains=search_guest)
            | Q(realname__contains=search_guest))  # Q 与或非
        if not guest_list:  # 增加 发布会名称 查询 联表查询
            guest_list = []
            event_list = Event.objects.filter(name__contains=search_guest)
            for event_id in event_list:
                guest = Guest.objects.filter(event_id=event_id)
                guest_list.extend(
                    guest)  # extend() 只能接收 list,且把这个 list 中的每个元素添加到原 list 中
        page = request.GET.get('page')
        contacts = paginator(guest_list, page)
        return render(request, 'sign/guest_manage.html', {
            'user': username,
            'guests': contacts,
            'search_guest': search_guest
        })
Exemple #2
0
def guest_manage(request):
    username = request.session.get('user', '')
    guest_list = Guest.objects.all()
    page = request.GET.get('page')
    contacts = paginator(guest_list, page)
    return render(request, 'sign/guest_manage.html', {
        'user': username,
        'guests': contacts
    })
Exemple #3
0
def event_manage(request):
    # username = request.COOKIES.get('user', '')  # 读取cookie
    username = request.session.get('user', '')  # 读取session
    event_list = Event.objects.all()
    page = request.GET.get('page')
    contacts = paginator(event_list, page)
    return render(request, 'sign/event_manage.html', {
        'user': username,
        'events': contacts
    })
Exemple #4
0
def search_name(request):
    username = request.session.get('user', '')
    search_name = request.GET.get('name', '')
    event_list = Event.objects.filter(name__contains=search_name)  # 包含
    page = request.GET.get('page')
    contacts = paginator(event_list, page)
    return render(request, 'sign/event_manage.html', {
        'user': username,
        'events': contacts,
        'search_name': search_name
    })
Exemple #5
0
def guest_manage(request):
    user_id = request.session.get('user_id', '')
    if not get_user(user_id):
        request.session['login_from'] = '/base/project/'
        return render(request, 'user/login_action.html')
    else:
        username = request.session.get('user', '')
        guest_list = Guest.objects.all()
        page = request.GET.get('page')
        contacts = paginator(guest_list, page)
        return render(request, 'sign/guest_manage.html', {
            'user': username,
            'guests': contacts
        })
Exemple #6
0
def event_manage(request):
    # username = request.COOKIES.get('user', '')  # 读取cookie
    user_id = request.session.get('user_id', '')
    if not get_user(user_id):
        request.session['login_from'] = '/base/project/'
        return render(request, 'user/login_action.html')
    else:
        username = request.session.get('user', '')  # 读取session
        event_list = Event.objects.all()
        page = request.GET.get('page')
        contacts = paginator(event_list, page)
        return render(request, 'sign/event_manage.html', {
            'user': username,
            'events': contacts
        })
Exemple #7
0
def search_name(request):
    user_id = request.session.get('user_id', '')
    if not get_user(user_id):
        request.session['login_from'] = '/base/project/'
        return render(request, 'user/login_action.html')
    else:
        username = request.session.get('user', '')
        search_name = request.GET.get('name', '')
        event_list = Event.objects.filter(name__contains=search_name)  # 包含
        page = request.GET.get('page')
        contacts = paginator(event_list, page)
        return render(request, 'sign/event_manage.html', {
            'user': username,
            'events': contacts,
            'search_name': search_name
        })