Exemple #1
0
def index(request):
    lists = get_list_or_404(List)
    polednimenu = get_list_or_404(PoledniMenu)
    products_by_type = {}    
    poledni_menu_stale = {}
    poledni_menu_weekly = {}
    poledni_menu_daily = {}
    for onelist in lists:
        list_id = onelist.id
        products_by_type[list_id] = Product.objects.filter(lists__id=list_id).filter(pub_date__lte=timezone.now()).all().order_by('product_type', 'product_order')
    
    date = datetime.date.today()
    start_week = date - datetime.timedelta(date.weekday())
    end_week = start_week + datetime.timedelta(5)

    for poledni in polednimenu:
        poledni_id = poledni.id
        poledni_menu_stale[poledni_id] = DailyProduct.objects.filter(valid_for_date__range=[start_week, end_week]).filter(dtype=1).all()
        poledni_menu_weekly[poledni_id] = DailyProduct.objects.filter(valid_for_date__range=[start_week, end_week]).filter(dtype=2).all()
        poledni_menu_daily[poledni_id] = DailyProduct.objects.filter(valid_for_date__range=[start_week, end_week]).filter(dtype=3).all().order_by('valid_for_date', 'ptype') 
         

    return render(request, 'home/index.html', {
        'lists': lists,
        'products_by_type' : products_by_type,
        'polednimenu' : polednimenu,
        'poledni_menu_stale' : poledni_menu_stale,
        'poledni_menu_weekly': poledni_menu_weekly,
        'poledni_menu_daily': poledni_menu_daily,
        'start_week' : start_week,
        'end_week': end_week,
    })
Exemple #2
0
def index(request):
    ''' Index '''
    content = {
        block.get_template_block_name(): block for block in [
            IntroContent.objects.first(),
            AboutContent.objects.first(),
            BenefitsContent.objects.first(),
            ServicesContent.objects.first(),
            TeamContent.objects.first(),
            GetInTouchContent.objects.first(),
        ]
    }

    numbers = get_list_or_404(Number)
    benefits = get_list_or_404(Benefit)
    employees = get_list_or_404(Employee)
    services = get_list_or_404(Service)
    contacts = get_object_or_404(Contact)

    return render(request, 'website/index.html', {
        'content': content,
        'numbers': numbers,
        'benefits': benefits,
        'contacts': contacts,
        'employees': employees,
        'services': services,
        'contacts': contacts
    })
Exemple #3
0
def home(request):
    """
    Home view
    """
    form = CustomSearchForm()
    medias = []
    # Latest workshop
    # get childs of event type id 32
    descendant_ids = EventType.objects.get(id=32).get_descendants(include_self=True).values_list('id', flat=True)
    w_medias = get_list_or_404(Media.objects.order_by('-archive__date'), archive__event__event_type__id__in=descendant_ids)[0]
    w_medias.bloc_title = u"Workshops"
    w_medias.see_others = u'selected_facets=event_type_exact:Séminaire / Conférence'
    medias.append(w_medias)
    # Latest concert
    c_medias = get_list_or_404(Media.objects.order_by('-time_stamp'), work__isnull=False)[0]
    c_medias.bloc_title = u"Concerts"
    c_medias.see_others = 'selected_facets=is_sound_exact:true'
    medias.append(c_medias)
    # "Images d'une œuvre"
    i_medias = get_list_or_404(Media.objects.order_by('-archive__date'), archive__set__id__in=[3220])[0]
    i_medias.bloc_title = u"Images d'une œuvre"
    i_medias.see_others = 'selected_facets=set_exact:Images d\'une œuvre (série documentaire)'
    medias.append(i_medias)
    # Other
    o_medias = Media.objects.order_by('-archive__date').exclude(archive__event__event_type__id__in=descendant_ids).exclude(work__isnull=False).exclude(archive__set__id__in=[3220])[0]
    o_medias.bloc_title = u"Others"
    o_medias.see_others = False
    medias.append(o_medias)
    return render_to_response('archives/home.html',
                              {'form': form, 'medias': medias, 'home':True},
                              context_instance=RequestContext(request))
Exemple #4
0
def cblog_datelist_article(request, year=None):
    if year:
        if request.user.is_authenticated():
            datelist=[{'year': year, 'entries':get_list_or_404(Entry, pub_date__year=year)}]
        else:
            datelist=[{'year': year, 'entries':get_list_or_404(Entry, pub_date__year=year,isdraft=False)}]

    else:
        datelist=[]
        if request.user.is_authenticated():
            dates=Entry.objects.all().datetimes('pub_date','year', order='DESC')
        else:
            dates=Entry.objects.filter(isdraft=False).datetimes('pub_date','year', order='DESC')

        for d in dates:
            entrylist=Entry.objects.filter(pub_date__year=d.year)
            datedict={}
            if entrylist:
                datedict['year']=d.year
                datedict['entries']=entrylist
                datelist.append(datedict)

    reqcontext={
        "article_year_list": datelist,
        "setting":setting
    }
    return render(request, "cblog/cblog_articlelist.html",reqcontext)
Exemple #5
0
def index(request):
    """
    Index
    """
    content = [
        Intro.objects.first(),
        WeAre.objects.prefetch_related('number_set').first(),
        WhatWeDo.objects.first(),
        GetInTouch.objects.first(),
    ]
    content_blocks = {
        block.get_template_block_name(): block for block in content
    }

    services = get_list_or_404(Service)
    projects = get_list_or_404(
        Project.objects.prefetch_related('stage')
    )
    employees = get_list_or_404(
        Employee.objects.prefetch_related('number_set')
    )
    contact = get_list_or_404(Contact)[0]

    return render(request, 'website/index.html', {
        'content_blocks': content_blocks,
        'projects': projects,
        'services': services,
        'employees': employees,
        'contact': contact,
    })
Exemple #6
0
def index(request):
    users = get_list_or_404(UserProfile)
    installs = get_list_or_404(Installation)
    if users and installs:
        return render(request, 'core/home.html', {'installs': len(installs), 'users': len(users), 'users_list': users})
    else:
        return render(request, 'core/home.html', {'installs': 0, 'users': 0})
Exemple #7
0
def HostAliasRest(request, hostpk=None, hostname=None, aliaspk=None, alias=None):
    result = 'ok'
    hostid = getReferredHost(hostpk, hostname)
    if request.method == "GET":
        if not alias:
            ha = get_list_or_404(HostAlias, hostid=hostid)
        else:
            if aliaspk:
                ha = get_list_or_404(HostAlias, hostid=hostid, pk=aliaspk)
            else:
                ha = get_list_or_404(HostAlias, hostid=hostid, alias=alias)
        sha = [HostAliasSerialize(h, request) for h in ha]
        ans = {'result': result, 'aliases': sha}
        return JsonResponse(ans)
    elif request.method == "POST":
        if HostAlias.objects.filter(hostid=hostid, alias=alias):
            result = 'duplicate'
        else:
            ha = HostAlias(hostid=hostid, alias=alias)
            ha.save()
            result = 'created'
    elif request.method == "DELETE":
        ha = get_object_or_404(HostAlias, hostid=hostid, alias=alias)
        ha.delete()
        result = 'deleted'

    aliases = []
    for h in HostAlias.objects.filter(hostid=hostid):
        aliases.append(HostAliasSerialize(h, request))
    ans = {'aliases': aliases, 'result': result}
    return JsonResponse(ans)
Exemple #8
0
def match_up_files(request):
    available_storage = get_list_or_404(
        filter_by_access(request.user, Storage, manage=True).order_by('title').values_list('id', 'title'))
    available_collections = get_list_or_404(filter_by_access(request.user, Collection, manage=True))

    class MatchUpForm(forms.Form):
        collection = forms.ChoiceField(
            choices=((c.id, c.title) for c in sorted(available_collections, key=lambda c: c.title)))
        storage = forms.ChoiceField(choices=available_storage)

    if request.method == 'POST':

        form = MatchUpForm(request.POST)
        if form.is_valid():
            collection = get_object_or_404(
                filter_by_access(request.user, Collection.objects.filter(id=form.cleaned_data['collection']),
                                 manage=True))
            storage = get_object_or_404(
                filter_by_access(request.user, Storage.objects.filter(id=form.cleaned_data['storage']), manage=True))

            job = JobInfo.objects.create(owner=request.user,
                                         func='storage_match_up_media', arg=json.dumps(dict(
                    collection=collection.id, storage=storage.id)))
            job.run()

            messages.success(request, message='Match up media job has been submitted.')
            return HttpResponseRedirect("%s?highlight=%s" % (reverse('workers-jobs'), job.id))
    else:
        form = MatchUpForm(request.GET)

    return render_to_response('storage_match_up_files.html',
                              {'form': form,
                              },
                              context_instance=RequestContext(request))
Exemple #9
0
def list(request, game_id, search):
    '''
    filter games based on a specific type (search)
    '''

    g = get_object_or_404(Game, pk=game_id)
    
    search_dict = { 'publisher' : 'Games published by ' + g.publisher,
        'genre' : 'Games in the ' + g.genre + ' genre',
        'max' : 'Games that support at least ' + str(g.maxplayers) + ' players', 
        'min' : 'Games that support at least ' + str(g.minplayers) + ' players',
        'year' :'Games published in ' +  g.year_published,
    }

    # TODO - figure out a better way to do this
    if search == 'publisher':
        games = get_list_or_404(Game, publisher=g.publisher)
    elif search == 'genre':
        games = get_list_or_404(Game, genre=g.genre)
    elif search == 'max':
        games = get_list_or_404(Game, maxplayers__gte=g.maxplayers)
    elif search == 'min':
        games = get_list_or_404(Game, minplayers__lte=g.minplayers)
    elif search == 'year':
        games = get_list_or_404(Game, year_published=g.year_published)
    else:
        games = []

    # create the page title
    title = (search_dict.get(search,''))
    
    return render_to_response('gameviewer/index.html', {'latest_game_list': games, 'title':title}) 
Exemple #10
0
def project(request, id):
    """
    Project
    """
    content = [
        WorkWithUs.objects.first()
    ]
    content_blocks = {
        block.get_template_block_name(): block
        for block in content
    }

    project = get_object_or_404(
        Project.objects.prefetch_related(
            'stage', 'functionality_set', 'scope_set'
        ),
        pk=id,
    )
    projects = get_list_or_404(Project)
    contact = get_list_or_404(Contact)[0]

    return render(request, 'website/project.html', {
        'content_blocks': content_blocks,
        'project': project,
        'projects': projects,
        'contact': contact,
    })
Exemple #11
0
def send_mail(request, vendor=None):
    try:
        order_list = []
        if vendor:
            context = get_list_or_404(Item, item_vendor=Vendor.objects.filter(vendor_name=vendor))

        else:
            context = get_list_or_404(Item)
        address = get_object_or_404(Vendor, vendor_name=vendor).vendor_email
        for i in context:
            if i.item_quantity <= i.item_order_point:
                order_list.append(i.item_name + " " + str(i.item_max_quantity - i.item_quantity) + "\n")
        s = "".join(order_list)
        try:
            email = EmailMessage(subject="Order for {0}".format(vendor),
                                 body=s,
                                 to=[address])
            email.send()
            messages.add_message(request, messages.INFO, "Email was sent to {}".format(vendor))
            return redirect('inventory:index')
        except Exception as e:
            return render(request, 'inventory/logout.html', {'message': e})

    except Exception as e:
        return render(request, 'inventory/logout.html', {'message': e})
def test_model(db):
    assert db is db

    foo = Foo.objects.create(text="hello")
    assert foo.ekey
    assert foo == Foo.objects.get_by_ekey(foo.ekey)
    assert foo == Foo.objects.get_by_ekey_or_404(foo.ekey)
    assert foo == Foo.objects.get(ekey=foo.ekey)
    assert foo == Foo.objects.filter(ekey=foo.ekey).get()

    foo = Foo2.objects.create(text="hello")
    assert foo.ekey
    assert foo == Foo2.objects.get_by_ekey(foo.ekey)
    assert foo == Foo2.objects.get_by_ekey_or_404(foo.ekey)
    assert foo == Foo2.objects.get(ekey=foo.ekey)
    assert foo == Foo2.objects.filter(ekey=foo.ekey).get()

    with pytest.raises(Http404):
        Foo.objects.get_by_ekey_or_404("123123")

    with pytest.raises(Http404):
        get_list_or_404(Foo, ekey="123123")

    with pytest.raises(Http404):
        get_object_or_404(Foo, ekey="123123")
Exemple #13
0
def list(request, game_id, search):
    """
    filter games based on a specific type (search)
    """

    g = get_object_or_404(Game, pk=game_id)

    search_dict = {
        "publisher": "Games published by " + g.publisher,
        "genre": "Games in the " + g.genre + " genre",
        "max": "Games that support at least " + str(g.maxplayers) + " players",
        "min": "Games that support at least " + str(g.minplayers) + " players",
        "year": "Games published in " + g.year_published,
    }

    # TODO - figure out a better way to do this
    if search == "publisher":
        games = get_list_or_404(Game, publisher=g.publisher)
    elif search == "genre":
        games = get_list_or_404(Game, genre=g.genre)
    elif search == "max":
        games = get_list_or_404(Game, maxplayers__gte=g.maxplayers)
    elif search == "min":
        games = get_list_or_404(Game, minplayers__lte=g.minplayers)
    elif search == "year":
        games = get_list_or_404(Game, year_published=g.year_published)
    else:
        games = []

    # create the page title
    title = search_dict.get(search, "")

    return render_to_response("gameviewer/index.html", {"latest_game_list": games, "title": title})
Exemple #14
0
def get_planet_points(planet):
    buildings = get_list_or_404(Building, planet=planet)
    defense = get_list_or_404(Defense, planet=planet)

    other_points = 0
    production_points = 0
    defense_points = 0

    for b in buildings:
        this_building_cost = b.get_total_cost()
        this_building_points = this_building_cost[0] + this_building_cost[1] + this_building_cost[2]

        if b.content_type.model_class() in [Supply1, Supply2, Supply3, Supply4, Supply12]:
            production_points += this_building_points
        else:
            other_points += this_building_points

    for d in defense:
        this_defense = d.as_real_class()
        this_defense_points = this_defense.count * (this_defense.cost[0] + this_defense.cost[1] + this_defense.cost[2])

        defense_points += this_defense_points

    planet_points = production_points + other_points + defense_points

    return planet_points, production_points, other_points, defense_points
Exemple #15
0
def find_records_without_media(request):
    available_storage = get_list_or_404(filter_by_access(request.user, Storage, manage=True).order_by('title').values_list('id', 'title'))
    available_collections = get_list_or_404(filter_by_access(request.user, Collection, manage=True))

    class SelectionForm(forms.Form):
        collection = forms.ChoiceField(choices=((c.id, c.title) for c in sorted(available_collections, key=lambda c: c.title)))
        storage = forms.ChoiceField(choices=available_storage)

    identifiers = records = []
    analyzed = False

    if request.method == 'POST':

        form = SelectionForm(request.POST)
        if form.is_valid():

            collection = get_object_or_404(filter_by_access(request.user, Collection.objects.filter(id=form.cleaned_data['collection']), manage=True))
            storage = get_object_or_404(filter_by_access(request.user, Storage.objects.filter(id=form.cleaned_data['storage']), manage=True))

            records = analyze_records(collection, storage)
            analyzed = True

            identifiers = FieldValue.objects.filter(field__in=standardfield('identifier', equiv=True),
                                                    record__in=records).order_by('value').values_list('value', flat=True)

    else:
        form = SelectionForm(request.GET)

    return render_to_response('storage_find_records_without_media.html',
                              {'form': form,
                               'identifiers': identifiers,
                               'records': records,
                               'analyzed': analyzed,
                               },
                              context_instance=RequestContext(request))
Exemple #16
0
def archive(request, year, month=None, template="news/archive.html"):
    year = int(year)

    if month is not None:
        month = int(month)

        articles = get_list_or_404(
            Article,
            pub_date__lte=datetime.date.today(),
            pub_date__month=month,
            pub_date__year=year,
            status='P',
        )

        date = datetime.date(year, month, 1)
        title = '%s' % date.strftime('%B %Y')
    else:
        articles = get_list_or_404(
            Article,
            pub_date__lte=datetime.date.today(),
            pub_date__year=int(year),
            status='P',
        )

        date = datetime.date(year, 1, 1)
        title = '%s' % date.strftime('%Y')

    return render_to_response(template, {
        'articles': articles,
        'date': date,
        'year': year,
        'month': month,
        'archives': get_archives(),
        'list_title': '%s Archive' % title,
    }, context_instance=RequestContext(request))
Exemple #17
0
def HostKeyRest(request, hostpk=None, hostname=None, keypk=None, key=None, value=None):
    result = 'ok'
    hostid = getReferredHost(hostpk, hostname)
    keyid = None

    # Get the id of the AllowedKey
    if keypk:
        ko = get_object_or_404(KeyValue, pk=keypk)
        keyid = ko.keyid
    if key:
        keyid = get_object_or_404(AllowedKey, key=key)
    if keyid:
        keytype = keyid.get_validtype_display()
    else:
        keytype = None

    if request.method == "GET":
        if not keyid:
            kvs = get_list_or_404(KeyValue, hostid=hostid)
        else:
            if keypk:
                kvs = get_list_or_404(KeyValue, hostid=hostid, pk=keypk)
            else:
                kvs = get_list_or_404(KeyValue, hostid=hostid, keyid=keyid)
        sha = [KeyValueSerialize(k, request) for k in kvs]
        return JsonResponse({'result': result, 'keyvalues': sha})
    elif request.method == "POST":
        origin = get_origin(request)
        if KeyValue.objects.filter(hostid=hostid, keyid=keyid, value=value):
            result = 'duplicate'
        elif KeyValue.objects.filter(hostid=hostid, keyid=keyid):
            if keytype == 'list':
                addKeytoHost(hostid=hostid, keyid=keyid, value=value, appendFlag=True, origin=origin)
                result = 'appended'
            else:
                try:
                    addKeytoHost(hostid=hostid, keyid=keyid, value=value, updateFlag=True, origin=origin)
                    result = 'updated'
                except HostinfoException as exc:    # pragma: no cover
                    result = 'failed %s' % str(exc)
        else:
            result = 'created'
            try:
                addKeytoHost(hostid=hostid, keyid=keyid, value=value, origin=origin)
            except HostinfoException as exc:    # pragma: no cover
                result = 'failed %s' % str(exc)
    elif request.method == "DELETE":
        result = 'deleted'
        if keytype == 'list':
            ha = get_object_or_404(KeyValue, hostid=hostid, keyid=keyid, value=value)
            ha.delete()
        else:
            ha = get_object_or_404(KeyValue, hostid=hostid, keyid=keyid)
            ha.delete()

    kvals = []
    for h in KeyValue.objects.filter(hostid=hostid).select_related('keyid').select_related('hostid'):
        kvals.append(KeyValueSerialize(h, request))
    return JsonResponse({'result': result, 'keyvalues': kvals})
Exemple #18
0
 def test_forms_include_all_waste_and_material_types(self):
     resp = material_search_view(self.request, self.project.id)
     waste_types = get_list_or_404(WasteType)
     material_types = get_list_or_404(MaterialType)
     for waste_type in waste_types:
         self.assertContains(resp, waste_type)
     for material_type in material_types:
         self.assertContains(resp, material_type)
Exemple #19
0
 def get(self,request,ptag):
     tagids = get_list_or_404(Tag,tagname__contains = ptag)
     tagwords = get_list_or_404(Vocab,category__in = tagids)
     template = loader.get_template('gre/tags.html')
     context = { 
         'tagwords':tagwords,
         'tag' : ptag
     }
     return HttpResponse(template.render(context,request))
Exemple #20
0
def list_rules(request):
    zone = get_list_or_404(models.zone)
    host = get_list_or_404(models.host)
    application = get_list_or_404(models.application)
    firewall = get_list_or_404(models.firewall)
    rule = get_list_or_404(models.rule)
    return render(
        request, "list_rules.html", {"host": host, "application": application, "firewall": firewall, "rule": rule}
    )
Exemple #21
0
def archives(request):
    # post_list = get_list_or_404(Article, draft=False)
    if not request.user.is_authenticated:
        post_list = get_list_or_404(Article, draft=False)
    else:
        post_list = get_list_or_404(Article)
    return render(
        request, "archives.html", {"post_list": post_list, "error": False}
    )
Exemple #22
0
    def get_queryset(self):
	page = 1
	if( self.kwargs.get('page') is not None ):
	    page = self.kwargs.get('page')
	if( self.request.user.is_authenticated() ):
	    imagesets = get_list_or_404(ImageSet.objects.order_by('created_at'), Q(published=True) | Q(owner=self.request.user) )
	else:
	    imagesets = get_list_or_404(ImageSet.objects.order_by('created_at'), published=True )
	paginator = Paginator(imagesets, 10)
	return paginator.page(page)
def course_index(request, **kwargs):
    if kwargs.has_key('year') and kwargs.has_key('term'):
        list = get_list_or_404(Course, year=kwargs['year'], term=kwargs['term'])
        return render_to_response('index.html', {'course_list':list, 'specific_term_course_index':(kwargs['year'],kwargs['term']), })
    elif kwargs.has_key('year'):
        list = get_list_or_404(Course, year=kwargs['year'])
        return render_to_response('index.html', {'course_list':list, 'specific_term_course_index':(kwargs['year'],None), })
    else:
        list = Course.objects.all().order_by('year', 'term')
    return render_to_response('index.html', {'course_list':list, 'course_index':'a',})
Exemple #24
0
def archiveview(request, pub_date):
    texts = thumbnails(get_list_or_404(Text.objects.order_by('-pub_date'), pub_date__gt=pub_date))
    videos = video_API_handler(get_list_or_404(Text.objects.order_by('-pub_date')))
    events = get_list_or_404(Text.objects.order_by('-pub_date'))
    return render_to_response('prekariatet/index.html', {
	    'pub_date':pub_date,
	    'texts':texts,
	    'videos':videos,
	    'events':events},
			      context_instance=RequestContext(request))
Exemple #25
0
	def get_queryset(self): #取得url中额外参数

		self.hetongNO = self.kwargs['hetongno'] #对应url配置中的关键字配置名称
		if self.hetongNO != 'null':

			self.fukuanmxlist = get_list_or_404(FukuanMX, hetongNO= self.hetongNO) #获得一个列表显示多个结果,get_object_or_404获得单个结果
			return FukuanMX.objects.filter(hetongNO =self.fukuanmxlist)
		else:
			self.fukuanmxlist = get_list_or_404(FukuanMX)
			return FukuanMX.objects.all()
Exemple #26
0
def category_tag_entries(request, slug, mode):
	if mode == 'category':
		extra_context = {'objects': get_list_or_404(Entry.published_objects.accessible_entries(request.user), category__slug=slug),
						'category': get_object_or_404(Category, slug=slug)}
	elif mode == 'tag':
		extra_context = {'objects': get_list_or_404(Entry.published_objects.accessible_entries(request.user), tags__slug__contains=slug),
						'tag': get_object_or_404(Tag, slug=slug)}
	else:
		raise Http404
	
	return paging(request, template='category_tags_list.html', extra_context=extra_context)
Exemple #27
0
def home(request):
	if not request.user.is_authenticated():
		return redirect('wishit:index')
	else:
		wishlists = get_list_or_404(WishList)
		wl_id = [wl.id for wl in wishlists]
		gifts = get_list_or_404(Gift, wish_list__in = wl_id)
		#gifts = get_list_or_404(Gift, )
		context = {'wishlist' : wishlists, 'gifts': gifts}
		context.update(csrf(request))
		return render(request, 'wishit/home.html', context)
Exemple #28
0
 def get_queryset(self):                            
     cat = self.kwargs["category"].split("/")
     self.category = get_object_or_404(Category,slug = cat.pop())
     if self.category:
         self.context_object_name = "ct"            
         categories_objects = get_list_or_404(TumbleItem, category=self.category)
         return categories_objects
     else:
         self.context_object_name = "ct"           
         tags = get_list_or_404(Tag, name=cat)
         return tags.taggit_taggeditem_items.get_query_set()    
Exemple #29
0
def details(request, item_id):
    result = check_login(request)
    if result is not None:
        return result
    items = get_list_or_404(LibItem, id=item_id)
    for item in items:
        if item.itemtype == 'Book':
            result = get_list_or_404(Book, id=item_id)
        else:
            result = get_list_or_404(Dvd, id=item_id)
    return render(request, 'libapp/Details.html', {'result': result})
Exemple #30
0
    def read(self, request, vendor, name, version=None):
        if version is not None:
            resource = get_object_or_404(CatalogueResource, vendor=vendor, short_name=name, version=version)
            data = get_resource_data(resource, request.user, request)
        else:
            if request.user.is_authenticated():
                resources = get_list_or_404(CatalogueResource.objects.filter(Q(vendor=vendor) & Q(short_name=name) & (Q(public=True) | Q(users=request.user) | Q(groups__in=request.user.groups.all()))).distinct())
            else:
                resources = get_list_or_404(CatalogueResource.objects.filter(Q(vendor=vendor) & Q(short_name=name) & Q(public=True)))
            data = get_resource_group_data(resources, request.user, request)

        return HttpResponse(json.dumps(data, sort_keys=True), content_type='application/json; charset=UTF-8')
Exemple #31
0
def approve_comment(request, pk):
    comment = get_list_or_404(Comment, pk=pk)[0]
    comment.approve()
    return redirect('post_detail', comment.post.pk)
Exemple #32
0
 def get(self, request, *args, **kwargs):
     serializer = self.get_serializer(get_list_or_404(
         self.get_queryset().all()),
                                      many=True,
                                      context={'request': request})
     return Response(serializer.data)
Exemple #33
0
def remove_comment(request, pk):
    comment = get_list_or_404(Comment, pk=pk)[0]
    comment_pk = comment.post.pk
    comment.delete()
    return redirect('post_detail', pk=comment_pk)
Exemple #34
0
 def list(self, request, *args, **kwargs):
     """Func retrieves user inventory by user id"""
     user_id = request.user.id
     self.queryset = get_list_or_404(Inventory, user=user_id)
     return super().list(request, *args, **kwargs)
Exemple #35
0
def detail(request, user_id):
    user = get_object_or_404(User, id=user_id)
    statuses = get_list_or_404(Status.objects.order_by('-created_at'), user=user)
    return render_to_response('harvester/detail.html', {'user': user, 'statuses':statuses})
Exemple #36
0
 def get_queryset(self):
     self.orderlist = get_list_or_404(OrderList,
                                      restaurant__id=self.kwargs['id'])
Exemple #37
0
 def get_question_id_list_in_theme(self):
     theme_list = get_list_or_404(Question, theme=self.theme)
     theme_id_list = []
     for q in theme_list:
         theme_id_list.append(q.id)
     return theme_id_list
Exemple #38
0
from .models import *
Exemple #39
0
def photos_sub_menu():
    sub_menus = get_list_or_404(models.Categorie)
    return sub_menus
Exemple #40
0
    def test_get_object_or_404(self):
        a1 = Author.objects.create(name="Brave Sir Robin")
        a2 = Author.objects.create(name="Patsy")

        # No Articles yet, so we should get a Http404 error.
        self.assertRaises(Http404, get_object_or_404, Article, title="Foo")

        article = Article.objects.create(title="Run away!")
        article.authors = [a1, a2]
        # get_object_or_404 can be passed a Model to query.
        self.assertEqual(
            get_object_or_404(Article, title__contains="Run"),
            article
        )

        # We can also use the Article manager through an Author object.
        self.assertEqual(
            get_object_or_404(a1.article_set, title__contains="Run"),
            article
        )

        # No articles containing "Camelot".  This should raise a Http404 error.
        self.assertRaises(Http404,
            get_object_or_404, a1.article_set, title__contains="Camelot"
        )

        # Custom managers can be used too.
        self.assertEqual(
            get_object_or_404(Article.by_a_sir, title="Run away!"),
            article
        )

        # QuerySets can be used too.
        self.assertEqual(
            get_object_or_404(Article.objects.all(), title__contains="Run"),
            article
        )

        # Just as when using a get() lookup, you will get an error if more than
        # one object is returned.

        self.assertRaises(Author.MultipleObjectsReturned,
            get_object_or_404, Author.objects.all()
        )

        # Using an EmptyQuerySet raises a Http404 error.
        self.assertRaises(Http404,
            get_object_or_404, Article.objects.none(), title__contains="Run"
        )

        # get_list_or_404 can be used to get lists of objects
        self.assertEqual(
            get_list_or_404(a1.article_set, title__icontains="Run"),
            [article]
        )

        # Http404 is returned if the list is empty.
        self.assertRaises(Http404,
            get_list_or_404, a1.article_set, title__icontains="Shrubbery"
        )

        # Custom managers can be used too.
        self.assertEqual(
            get_list_or_404(Article.by_a_sir, title__icontains="Run"),
            [article]
        )

        # QuerySets can be used too.
        self.assertEqual(
            get_list_or_404(Article.objects.all(), title__icontains="Run"),
            [article]
        )
Exemple #41
0
def index(request):
    groups = get_list_or_404(ProductGroup)
    return render(request, 'products/index.html', {'groups': groups})
Exemple #42
0
def all(request):
    posts = get_list_or_404(Post)
    context = {'posts': posts}
    return render(request, 'blog/all.html', context)
Exemple #43
0
def gallery_home(request):
    categories = get_list_or_404(Category)
    return render(request, 'gallery/gallery_home.html',
                  {'categories': categories})
Exemple #44
0
    searchobj = DataSearch.objects.create(keyword=request.POST['keyword'])
    # make searches here
    search_youtube(request.POST['keyword'], searchobj)
    search_spotify(request.POST['keyword'], searchobj)
    return HttpResponseRedirect('/musicsearch/results/' + str(searchobj.id))

# render search result page
def results(request, result_id):
    context = {}
# HAE DATASEARCHIT MOLEMMISTA PALVELUISTA JA NIILLA VASTA TRACKIT
    datasearch = DataSearch.objects.get(id=result_id)
    
    result_list = get_list_or_404(SearchResult, data_search_id=datasearch.id)
        context['tracks'] = ()
    for(result in result_list)
        context['tracks'].append() get_list_or_404(Track, search_result_id=result.id)
    
    return render(request, 'musicsearch/results.html', context)

def search_youtube(keyword, ds_id):
    DEVELOPER_KEY = "AIzaSyBcUxRjftWVZdtrhKrvhbUxnTQ6Jzbd7SA"
    YOUTUBE_API_SERVICE_NAME = "youtube"
    YOUTUBE_API_VERSION = "v3"
    
    youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY)
    search_response = youtube.search().list(q=keyword, part="id,snippet", maxResults=10).execute()

    serres = SearchResult.objects.create(data_search_id=ds_id, service='youtube')
    
    for search_result in search_response.get("items", []):
        if search_result["id"]["kind"] == "youtube#video":
Exemple #45
0
def post_publish(request, pk):
    print('*' * 10, pk)
    post = get_list_or_404(Post, pk=pk)[0]
    print('*' * 100, post)
    post.publish()
    return redirect('post_detail', pk)
Exemple #46
0
def comment_list(request):
    comments = get_list_or_404(Comment)
    serializer = CommentSerializer(comments, many=True)
    return Response(serializer.data)
Exemple #47
0
def index(req):
    context = {'users': get_list_or_404(User)}
    return render(req, 'users/index.html', context)
Exemple #48
0
def get_User(ids):

    u = get_list_or_404(User, is_staff=0, is_superuser=0)

    return u
Exemple #49
0
class PromotionsList(LoginRequiredMixin, ListView):
    template_name = 'mobile_api/news_promotions_list.html'
    queryset = get_list_or_404(Promotion)
Exemple #50
0
 def get(self, request):
     pks = get_list_or_404(QuestionAndAnswers, user=request.user)
     QA = map(self.getEl, pks)
     serializers = QuestionSerializer(QA, many=True)
     return Response({"value": serializers.data})
Exemple #51
0
 def get_question_id_list_in_ticket(self):
     question_list = get_list_or_404(Question, ticket=self.ticket)
     question_id_list = []
     for q in question_list:
         question_id_list.append(q.id)
     return question_id_list
Exemple #52
0
def view(request):
    records = get_list_or_404(Record)
    context = {}
    context['records'] = records
    return render(request, 'record/view.html', context)
Exemple #53
0
def index(request):
    sections = get_list_or_404(Section)
    return render(request, 'forum/index.html', {'sections': sections})
Exemple #54
0
def anketdetay(request,id):
  
    newAnket=get_list_or_404(Anket,id=id)
    newAnket=newAnket[0]
    return render (request,"anketdetay.html",{"newAnket":newAnket})
Exemple #55
0
def homesindistrictwithnames(request):
    #print('in homesindistrictwithnames')

    resolver_match = resolve(request.path)
    url_path = resolver_match.url_name
    #print('url path = ' + resolver_match.url_name)
    camp_array = []
    query_information = "Address level voter information"

    city = request.GET.get('city', '')
    street_name = request.GET.get('street_name', '')
    precinct = request.GET.get('precinct', '')
    state_rep_district = request.GET.get('state_rep_district', '')
    state_senate_district = request.GET.get('state_senate_district', '')
    congressional_district = request.GET.get('congressional_district', '')
    request_controller = request.GET.get('request_controller', '')
    vstat_id = request.GET.get('vstat_id', '')

    #print('printing this for debugging.....  :)')
    #print('city ' + city)
    #print('street name is ' + street_name)
    #print('precinct name is ' + precinct)
    #print('state_rep_district ' + state_rep_district)
    #print('state_senate_district ' + state_senate_district)
    #print('congressional_district ' + congressional_district)
    #print('request_controller ' + request_controller) # this is covered in if statement below... :)

    # this view can be called from several urls...
    # cag20160326 - think about using a dictionary for these..??
    #  - like this..  - request_controller = rc_dict[request_controller]
    #  - note - just need to know how to handle when it is not in the dict...
    if request_controller == 'city':
        list_description = "Cities/ Towns include "
        #print('request_controller is city ')
    elif request_controller == 'housedistricts':
        list_description = "State Rep Districts include "
        #print('request_controller is housedistricts ')
    elif request_controller == 'senatedistricts':
        list_description = "Senate Districts include "
        #print('request_controller is senatedistricts ')
    else:
        print('error homesonstreet with request_controller ' +
              request_controller)
        #return HttpResponse("Error with request_controller value " + request_controller)
        # above return prob wont' work cuz this view is called from an ajax call...

    # cag20160323 todo: change this from fullview to elections or
    #    update fullview table with more data so it isn't so restrictive
    # cag20160326 - created fulldav to manage detectavoter info

    #print(' in homesindistrictwithnames and request_controller = ' + request_controller )
    #print('street_name = '+ street_name)
    #print('city = '+city)
    #print('state_rep_district = '+state_rep_district)
    #print('vstat_id = '+vstat_id)

    # cag20160322 todo: add precincts to this logic at some point :)
    if request_controller == 'city':
        try:
            print('querying city ')
            homesjson = serializers.serialize("json", get_list_or_404(Fulldav.objects.\
                filter(Q(swg2014=True)|Q(swp2014=True)|Q(pe2012=True)).\
                filter(precinct=precinct).\
                filter(street_name=street_name).\
                filter(city=city).\
                order_by('street_number', 'unit')))
        except:
            return HttpResponse(
                "Error retrieving voters on selected street in city/ town " +
                city)
    elif request_controller == 'housedistricts':
        try:
            print('querying house districts')
            homesjson = serializers.serialize("json", get_list_or_404(Fulldav.objects.\
                filter(Q(swg2014=True)|Q(swp2014=True)|Q(pe2012=True)).\
                filter(precinct=precinct).\
                filter(street_name=street_name).\
                filter(city=city).\
                filter(state_rep_district=state_rep_district).\
                order_by('street_number', 'unit')))
        except:
            return HttpResponse(
                "Error retrieving voters on selected street in house district "
                + state_rep_district)
    elif request_controller == 'senatedistricts':
        try:
            print('querying senate districts')
            homesjson = serializers.serialize("json", get_list_or_404(Fulldav.objects.\
                filter(Q(swg2014=True)|Q(swp2014=True)|Q(pe2012=True)).\
                filter(precinct=precinct).\
                filter(street_name=street_name).\
                filter(city=city).\
                filter(state_senate_district=state_senate_district).\
                order_by('street_number', 'unit')))
        except:
            return HttpResponse(
                "Error retrieving voters on selected street in senate district "
                + state_senate_district)
    else:
        return HttpResponse("Error processing request  :)")
    # cag20160326 note - changed above queries from filtering using vstat_id cuz
    #       the vs rows can have many roes -  granular - by precinct, rep etc.. so two people on the same street could be in a different city

    return JsonResponse(homesjson, content_type="application/json", safe=False)
Exemple #56
0
def vstats(request):
    #print ('in vstats view')
    resolver_match = resolve(request.path)
    url_path = resolver_match.url_name
    print('url path = ' + resolver_match.url_name)
    camp_array = []
    query_information = "City and street level voter totals"

    # this view can be called from several urls...
    # think about changing to a dictionary so we don't need all these if stmts.. :)
    if url_path == 'city':
        request_controller = url_path
        list_description = "Cities/ Towns include "
    elif url_path == 'housedistricts':
        request_controller = url_path
        list_description = "State Rep Districts include "
    elif url_path == 'senatedistricts':
        request_controller = url_path
        list_description = "Senate Districts include "
    else:
        return HttpResponse("Error with url path  :)")

    active_campaign_status = "A"

    if request.user.is_authenticated():
        sitevisitor = request.user.username.title()
        try:
            campaign = get_list_or_404(CampaignAssignment.objects.\
            filter(campaign_username=sitevisitor).\
            filter(status=active_campaign_status).\
            filter(campaign_type=request_controller))
        except:
            return HttpResponse(
                "You must have an active campaign set up to access this  :)")

        # get the campaign information for this person
    else:
        return HttpResponse("You must be logged in to see this content  :)")
        # if they are not authenticated, remind them to log in..
        # put something here telling them no can do...

    ctr = 0
    #print('campaigns set up for ' + sitevisitor +" = ")
    for c in campaign:
        ctr += 1
        camp_array.append(c.campaign_type_value.title())
        #print (c.campaign_type_value)

    town_list = tuple(camp_array)

    if request_controller == 'city':
        try:
            vstats_table = Fullvs.objects.filter(
                reduce(operator.or_,
                       (Q(city=param1) for param1 in camp_array)))
        except:
            return HttpResponse(
                "Error retrieving homes in city/ town campaign  :)")
    elif request_controller == 'housedistricts':
        try:
            vstats_table = Fullvs.objects.filter(
                reduce(operator.or_, (Q(state_rep_district=param1)
                                      for param1 in camp_array)))
        except:
            return HttpResponse(
                "Error retrieving homes in house district campaign  :)")
    elif request_controller == 'senatedistricts':
        try:
            vstats_table = Fullvs.objects.filter(
                reduce(operator.or_, (Q(state_senate_district=param1)
                                      for param1 in camp_array)))
        except:
            return HttpResponse(
                "Error retrieving homes in senate district campaign  :)")
    else:
        return HttpResponse("Error processing request  :)")

    data = {
        'campaign_username': request.user.username,
        'ct_id': 999999999,
    }
    form = VoterTagsForm(data)  # bound to the campaign_username

    # cag20160404 - todo: check out field.disabled
    #    - https://docs.djangoproject.com/en/1.9/ref/forms/fields/

    #for v in vstats_table:
    #    print (v.vstat_id)

    context = {
        'vstats_table': vstats_table,
        'sitevisitor': sitevisitor,
        'town_list': town_list,
        'query_information ': query_information,
        'request_controller': request_controller,
        'list_description': list_description,
        'form': form,
    }
    return render(request, 'elections/electablevstatsdatatable2.html', context)
Exemple #57
0
def categories(request):
    categories = get_list_or_404(Categories)
    return render(request, 'Website/categories.html',
                  {'categories': categories})
Exemple #58
0
def specificpartylist(request,
                      party):  # returns a list of voters in a specific party
    voter_table = get_list_or_404(Fulldav, party_code=party)[:250]
    party_specified = party  # cag! success: set party variable in context so it can be referenced in template
    context = {'voter_table': voter_table, 'party_specified': party_specified}
    return render(request, 'elections/votertable.html', context)
def detail(request):
    form = FilterResultsForm(request.POST or None)
    search = request.GET['q']
    properties = get_list_or_404(Properties, locality=search)
    images = []
    images_filter = []
    for property in properties:
        images.append(ImageElement.objects.filter(post=property).first())

    if request.method == 'POST':
        if request.POST['sort_filter'] == "filter":
            property_type = request.POST['property_type']
            bhk = request.POST['BHK']
            price = request.POST['price']
            construction_status = request.POST['construction_status']
            area = request.POST['area']

            if property_type != 'No Preference':
                if bhk != 'No Preference':
                    if price != 'No Preference':
                        if construction_status != 'No Preference':
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    price=price,
                                    construction_status=construction_status,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    price=price,
                                    construction_status=construction_status)
                        else:
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    price=price,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    price=price)
                    else:
                        if construction_status != 'No Preference':
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    construction_status=construction_status,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    construction_status=construction_status)
                        else:
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk)
                else:
                    if price != 'No Preference':
                        if construction_status != 'No Preference':
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    price=price,
                                    construction_status=construction_status,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    price=price,
                                    construction_status=construction_status)
                        else:
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    price=price,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    price=price)
                    else:
                        if construction_status != 'No Preference':
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    construction_status=construction_status,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    construction_status=construction_status)
                        else:
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type)
            else:
                if bhk != 'No Preference':
                    if price != 'No Preference':
                        if construction_status != 'No Preference':
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    price=price,
                                    construction_status=construction_status,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    price=price,
                                    construction_status=construction_status)
                        else:
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    price=price,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    price=price)
                    else:
                        if construction_status != 'No Preference':
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    construction_status=construction_status,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    construction_status=construction_status)
                        else:
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    property_type=property_type,
                                    BHK=bhk)
                else:
                    if price != 'No Preference':
                        if construction_status != 'No Preference':
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    price=price,
                                    construction_status=construction_status,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    price=price,
                                    construction_status=construction_status)
                        else:
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    price=price,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties, locality=search, price=price)
                    else:
                        if construction_status != 'No Preference':
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    construction_status=construction_status,
                                    area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties,
                                    locality=search,
                                    construction_status=construction_status)
                        else:
                            if area != 'No Preference':
                                properties_filter = get_list_or_404(
                                    Properties, locality=search, area=area)
                            else:
                                properties_filter = get_list_or_404(
                                    Properties, locality=search)

            for property in properties_filter:
                images_filter.append(
                    ImageElement.objects.filter(post=property).first())

            return render(
                request, 'ecommerce/detail.html', {
                    'properties': properties_filter,
                    'images': images_filter,
                    'form': form
                })

        elif request.POST['sort_filter'] == "sort":
            value = request.POST['sort']
            if value == 'relevance':
                images = sorted(images,
                                key=lambda image: image.post.property_title)
            elif value == 'price_low_to_high':
                images = sorted(images, key=lambda image: image.post.price)
            elif value == 'price_high_low':
                images = reversed(
                    sorted(images, key=lambda image: image.post.price))
            elif value == 'sqft_low_high':
                images = sorted(images, key=lambda image: image.post.area)
            elif value == 'sqft_high_low':
                images = reversed(
                    sorted(images, key=lambda image: image.post.area))
            elif value == 'latest':
                images = reversed(
                    sorted(images,
                           key=lambda image: image.post.post_date_time))

            return render(request, 'ecommerce/detail.html', {
                'properties': properties,
                'images': images,
                'form': form
            })

    return render(request, 'ecommerce/detail.html', {
        'properties': properties,
        'images': images,
        'form': form
    })
Exemple #60
0
def homesonstreet(request):
    #print('in homesonstreet')

    resolver_match = resolve(request.path)
    url_path = resolver_match.url_name
    #print('url path = ' + resolver_match.url_name)
    camp_array = []
    query_information = "City and street level voter totals"

    city = request.GET.get('city', '')
    street_name = request.GET.get('street_name', '')
    precinct = request.GET.get('precinct', '')
    state_rep_district = request.GET.get('state_rep_district', '')
    state_senate_district = request.GET.get('state_senate_district', '')
    congressional_district = request.GET.get('congressional_district', '')
    request_controller = request.GET.get('request_controller', '')

    #print('in homesonstreet view and printing this for debugging.....  :)')
    #print('city ' + city)
    #print('street name is ' + street_name)
    #print('precinct name is ' + precinct)
    #print('state_rep_district ' + state_rep_district)
    #print('state_senate_district ' + state_senate_district)
    #print('congressional_district ' + congressional_district)
    #print('request_controller ' + request_controller)

    # this view can be called from several urls...
    if request_controller == 'city':
        list_description = "Cities/ Towns include "
        #print('request_controller is city ')
    elif request_controller == 'housedistricts':
        list_description = "State Rep Districts include "
        #print('request_controller is housedistricts ')
    elif request_controller == 'senatedistricts':
        list_description = "Senate Districts include "
        #print('request_controller is senatedistricts ')
    else:
        #print('error homesonstreet with request_controller ' + request_controller)
        return HttpResponse("Error with request_controller value " +
                            request_controller)

    #  "GET" the above fields from the data passed in the ajax call in the getdata function
    # make sure we gether the data from vs which has the stats..

    if request_controller == 'city':
        try:
            homesjson = serializers.serialize("json", get_list_or_404(Fullvstats.objects.\
                filter(precinct=precinct).\
                filter(street_name=street_name).\
                filter(city=city)))
        except:
            return HttpResponse(
                "Error retrieving voters on selected street in city/ town " +
                city)
    elif request_controller == 'housedistricts':
        try:
            homesjson = serializers.serialize("json", get_list_or_404(Fullvstats.objects.\
                filter(precinct=precinct).\
                filter(street_name=street_name).\
                filter(state_rep_district=state_rep_district)))
        except:
            return HttpResponse(
                "Error retrieving voters on selected street in house district "
                + state_rep_district)
    elif request_controller == 'senatedistricts':
        try:
            homesjson = serializers.serialize("json", get_list_or_404(Fullvstats.objects.\
                filter(precinct=precinct).\
                filter(street_name=street_name).\
                filter(state_senate_district=state_senate_district)))
        except:
            return HttpResponse(
                "Error retrieving voters on selected street in senate district "
                + state_senate_district)
    else:
        return HttpResponse("Error processing request  :)")

    # what is the below code doing????
    response_data = {}
    try:
        response_data['result'] = 'Success'
        response_data['message'] = list(republican_list)
    except:
        response_data['result'] = 'Rats'
        response_data['message'] = 'sub process did not execute properly'

    return JsonResponse(homesjson, content_type="application/json", safe=False)