Exemplo n.º 1
0
def companies(request):
    now = timezone.now()
    company_list = Company.objects.filter(
        deleted=False, is_active=True).exclude(is_active=False, deleted=True)
    events = Event.objects.filter(
        is_active=True).order_by('-start_date').filter(
            end_date__gt=now).filter(deleted=False).filter(
                company__deleted=False, company__is_active=True)[:13]
    company_product_or_services = CompanyProductOrService.objects.filter(
        active=True).filter(
            company__deleted=False,
            company__is_active=True).order_by('?').filter(deleted=False)[:7]
    # contact_list = Contacts.objects.all()
    #paginationa yeniden baxilacaq
    paginator = FlynsarmyPaginator(
        company_list, 25, adjacent_pages=3)  # Show 25 contacts per page

    page = request.GET.get('page')  #page check is tam eded
    try:
        companies = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        companies = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        companies = paginator.page(paginator.num_pages)

    context = {
        'companies': companies,
        'company_product_or_services': company_product_or_services,
        'events': events,
    }
    return render(request, 'company/companies.html', context=context)
Exemplo n.º 2
0
def events(request):
    now = timezone.now()
    rand_events = Event.objects.filter(is_active=True).order_by('?').filter(
        end_date__gt=now).filter(deleted=False).filter(
            company__deleted=False, company__is_active=True)[:13]
    rand_company_product_or_services = CompanyProductOrService.objects.filter(
        active=True).filter(
            company__deleted=False,
            company__is_active=True).order_by('?').filter(deleted=False)[:7]
    event_list = Event.objects.filter(is_active=True).filter(
        deleted=False).filter(company__deleted=False,
                              company__is_active=True).order_by('start_date')
    # .filter(start_date__gte=now).filter(end_date__lte=now)[:18]
    # contact_list = Contacts.objects.all()
    paginator = FlynsarmyPaginator(
        event_list, 30, adjacent_pages=3)  # Show 25 contacts per page

    page = request.GET.get('page')  #page check is tam eded
    try:
        events = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        events = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        events = paginator.page(paginator.num_pages)
    context = {
        'events': events,
        'rand_events': rand_events,
        'rand_company_product_or_services': rand_company_product_or_services,
    }
    return render(request, 'events/events.html', context=context)
Exemplo n.º 3
0
def admin_all_customers(request):
    context = base_auth(req=request)
    user = request.user
    profile = get_object_or_404(Profile, user=user)
    if profile.type == 'admin-person':
        customer_list = Location.objects.all()
        # company_product_or_service_list = CompanyProductOrService.objects.filter(deleted=False)
        # .filter(start_date__gte=now).filter(end_date__lte=now)[:18]
        # contact_list = Contacts.objects.all()
        paginator = FlynsarmyPaginator(
            customer_list, 30, adjacent_pages=3)  # Show 25 contacts per page

        page = request.GET.get('page')  # page check is tam eded
        try:
            customers = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            customers = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            customers = paginator.page(paginator.num_pages)
        context['customers'] = customers
        context['page'] = page
    else:
        raise Http404
    return render(request,
                  'userprofile/admin/all_customers.html',
                  context=context)
Exemplo n.º 4
0
def busines(
    request,
    b_id,
    bc_slug,
):
    now = timezone.now()
    datas = None
    data_list = None
    busines = get_object_or_404(Businnes, id=b_id, active=True)
    rand_events = Event.objects.filter(is_active=True).filter(
        businness_types=busines).filter(
            businness_types__parent=busines).filter(end_date__gt=now).filter(
                deleted=False).filter(
                    company__deleted=False,
                    company__is_active=True).order_by('?')[:13]
    rand_company_product_or_services = CompanyProductOrService.objects.filter(
        active=True).filter(businness_types=busines).filter(
            businness_types__parent=busines).filter(deleted=False).filter(
                company__deleted=False,
                company__is_active=True).order_by('?')[:7]

    if bc_slug == 'events':
        data_list = Event.objects.filter(
            company__businnes_type=busines).filter(is_active=True).filter(
                deleted=False).filter(
                    company__deleted=False,
                    company__is_active=True).order_by('-start_date')
    elif bc_slug == 'companies':
        data_list = Company.objects.filter(businnes_type__id=busines.id)
        # return HttpResponse(busines.id)
    elif bc_slug == 'products-or-services':
        data_list = CompanyProductOrService.objects.filter(
            company__businnes_type=busines).filter(company__deleted=False,
                                                   company__is_active=True)
    else:
        raise Http404

    paginator = FlynsarmyPaginator(
        data_list, 24, adjacent_pages=3)  # Show 25 contacts per page

    page = request.GET.get('page')  #page check is tam eded
    try:
        datas = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        datas = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        datas = paginator.page(paginator.num_pages)
    context = {
        'busines': busines,
        'datas': datas,
        'bc_slug': bc_slug,
        'rand_events': rand_events,
        'rand_company_product_or_services': rand_company_product_or_services,
        # 'company_products_or_services':company_products_or_services,
    }
    return render(request, 'company/business.html', context=context)
Exemplo n.º 5
0
def index(request):
    ordenar = request.GET.get('ordenar', 'id')
    genero = request.GET.get('genero', 'todos')
    pais = request.GET.get('pais', 'todos')
    formato = request.GET.get('formato', 'todos')
    vistas = request.GET.get('vistas', 'todas')

    ord = 'peliculas_pelicula.'+ordenar
    if ordenar == 'id':
        ord = '-' + ord

    kwargs = {}
    kwargs_ex = {}
    if genero != 'todos':
        kwargs['genero__nombre'] = genero
    if pais != 'todos':
        kwargs['pais'] = pais
    if formato != 'todos':
        kwargs['categorias__nombre'] = formato

    inner_qs = Vista.objects.filter(usuario=request.user.id).values('pelicula')
    if vistas == 'si':
        kwargs['id__in'] = inner_qs
    elif vistas == 'no':
        kwargs_ex['id__in'] = inner_qs

    num_pelis = Pelicula.objects.filter(**kwargs).exclude(**kwargs_ex).count()
    lista = Pelicula.objects.filter(**kwargs).exclude(**kwargs_ex).prefetch_related('direccion','genero','reparto').order_by(ord)

    paginator = FlynsarmyPaginator(lista, 10, adjacent_pages=3)

    try:
        page = int(request.GET.get('page', '1'))
    except ValueError:
        page = 1

    try:
        pelis = paginator.page(page)
    except (EmptyPage, InvalidPage):
        pelis = paginator.page(paginator.num_pages)

    filtro = FiltroForm(initial={'ordenar': ordenar, 'genero': genero, 'pais': pais, 'formato': formato,
                                 'vistas': vistas})

    return render_to_response('peliculas/index.html', {'lista': pelis, 'num_pelis': num_pelis, 'filtro': filtro,
                                                       'ordenar': ordenar, 'genero': genero, 'pais': pais,
                                                       'formato': formato, 'vistas': vistas},
                              context_instance=RequestContext(request))
Exemplo n.º 6
0
def search(request, sc_slug):
    now = timezone.now()
    search_word = request.GET.get('search')
    businnes_g = request.GET.get('businnes')
    regions_g = request.GET.get('regions')
    if search_word:
        search_word = strip_tags(search_word)
    if businnes_g:
        businnes_g = strip_tags(businnes_g)
    if regions_g:
        regions_g = strip_tags(regions_g)
        if regions_g:
            try:
                int(regions_g)
                # return True
            except:
                raise Http404
    rand_events = Event.objects.filter(is_active=True).order_by('?').filter(
        end_date__gt=now).filter(deleted=False).filter(
            company__deleted=False, company__is_active=True)[:13]
    rand_company_product_or_services = CompanyProductOrService.objects.filter(
        active=True).order_by('?').filter(deleted=False).filter(
            company__deleted=False, company__is_active=True)[:7]
    search_content = sc_slug
    datas = None
    # data_list = None

    if search_content == 'events':
        data_list = Event.objects.filter().filter(deleted=False,
                                                  is_active=True).filter(
                                                      company__deleted=False,
                                                      company__is_active=True)
        if search_word and search_word.strip() != '':
            if data_list:

                data_list = data_list.filter(
                    Q(name__icontains=search_word)
                    | Q(company__name__icontains=search_word) |
                    Q(company_product_or_service__name__icontains=search_word)
                    |
                    Q(company_product_or_service__product_or_service__name__icontains
                      =search_word)).filter(is_active=True).filter(
                          deleted=False)
        if businnes_g and businnes_g.strip() != '':
            # data_list = Com.objects.filter()
            if data_list:
                data_list = data_list.filter(
                    Q(businness_types__id=businnes_g)
                    | Q(company__businnes_type__id=businnes_g))
        if regions_g and str(regions_g).strip() != '':
            if data_list:
                data_list = data_list.filter(company__region=regions_g)
        else:
            data_list.filter(id=0)

    elif search_content == 'companies':
        data_list = Company.objects.filter().filter(is_active=True).filter(
            deleted=False)
        if search_word and search_word != '':
            if data_list:
                data_list = data_list.filter(
                    Q(name__icontains=search_word)
                    | Q(slogan__icontains=search_word)
                    | Q(email__icontains=search_word)
                    | Q(profile__user__first_name__icontains=search_word)
                    | Q(profile__user__last_name__icontains=search_word))
        if businnes_g:
            if data_list:
                data_list = data_list.filter(Q(businnes_type__id=businnes_g))
        if regions_g:
            if data_list:
                data_list = data_list.filter(company__region=regions_g)
        else:
            data_list.filter(id=0)
    elif search_content == 'products-or-services':
        data_list = CompanyProductOrService.objects.filter(active=True).filter(
            deleted=False).filter(company__deleted=False,
                                  company__is_active=True)
        if search_word and search_word != '':
            if data_list:
                data_list = data_list.filter(
                    Q(name__icontains=search_word)
                    | Q(slogan__icontains=search_word)
                    | Q(description__icontains=search_word)
                    | Q(company__name=search_word)
                    |
                    Q(company__profile__user__first_name__icontains=search_word
                      )
                    |
                    Q(company__profile__user__last_name__icontains=search_word)
                )
        if businnes_g:
            if data_list:
                data_list = data_list.filter(
                    Q(businness_types__id=businnes_g)
                    | Q(company__businnes_type__id=businnes_g))
        if regions_g:
            if data_list:
                data_list = data_list.filter(company__region=regions_g)
        else:
            data_list.filter(id=0)
    else:
        raise Http404
    if data_list:
        paginator = FlynsarmyPaginator(
            data_list, 30, adjacent_pages=3)  # Show 25 contacts per page

        page = request.GET.get('page')  #page check is tam eded
        try:
            datas = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            datas = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            datas = paginator.page(paginator.num_pages)
    # else:
    context = {
        'datas': datas,
        'search_content': search_content,
        'search_word': search_word,
        'businnes_g': businnes_g,
        'regions_g': regions_g,
        'rand_events': rand_events,
        'rand_company_product_or_services': rand_company_product_or_services,
    }
    # return render(request, 'home/index.html', context=context)
    return render(request, 'home/search.html', context=context)