Viewability contribution to request..
504595
function ViewabilityContributor(viewabilityAmount) {
  function contributeViewability(ttxRequest) {
    const req = Object.assign({}, ttxRequest);
    const imp = req.imp = req.imp.map(impItem => Object.assign({}, impItem));
    const banner = imp[0].banner = Object.assign({}, imp[0].banner);
    const ext = banner.ext = Object.assign({}, banner.ext);
    const ttx = ext.ttx = Object.assign({}, ext.ttx);

    ttx.viewability = { amount: isNaN(viewabilityAmount) ? viewabilityAmount : Math.round(viewabilityAmount) };

    return req;
  }

  return contributeViewability;
}
1360593
def can_view(self, user):
        """"""
        return user in self.group.users or self.project.can_view(user)
305315
public void viewAccepted(View new_view) {
        List<Address> new_mbrs=new_view.getMembers();

        if(new_mbrs != null) {
            sendViewChangeNotifications(new_view, new_mbrs, new ArrayList<>(members)); // notifies observers (joined, left)
            members.clear();
            members.addAll(new_mbrs);
        }
    }
1370821
def all_requests_view(request):
    '''
    
    '''
    # Pseudo-dictionary, actually a list with items of form
    # (request_type.name.title(), number_of_type_requests, name, enabled,
    # glyphicon)
    types_dict = list()
    for request_type in RequestType.objects.all():
        requests = Request.objects.filter(request_type=request_type)
        # Hide the count for private requests
        if not request_type.managers.filter(incumbent__user=request.user):
            requests = requests.exclude(
                ~Q(owner__user=request.user), private=True,
                )

        number_of_requests = requests.count()
        types_dict.append((
            request_type.name.title(), number_of_requests,
            request_type.url_name, request_type.enabled,
            request_type.glyphicon,
            ))
    return render_to_response('all_requests.html', {
        'page_name': "Archives - All Requests",
        'types_dict': types_dict,
        }, context_instance=RequestContext(request))
473686
def my_requests_view(request):
    '''
    
    '''
    page_name = "Your Requests"
    userProfile = UserProfile.objects.get(user=request.user)
    my_requests = Request.objects.filter(owner=userProfile)
    # A pseudo dictionary, actually a list with items of form
    # (request_type.name.title(), request_form, type_manager, [(request,
    # [list_of_request_responses], response_form, upvote, vote_form),...],
    # relevant_managers)
    request_dict = list()
    for request_type in RequestType.objects.all():
        relevant_managers = request_type.managers.filter(active=True)
        type_manager = any(i.incumbent == userProfile for i in
                           relevant_managers)
        # Items are of form (request, [list_of_request_responses],
        # response_form),...])
        requests_list = list()
        type_requests = my_requests.filter(request_type=request_type)
        for req in type_requests:
            responses_list = Response.objects.filter(request=req)
            if type_manager:
                response_form = ManagerResponseForm(
                    request.POST if "add_response-{0}".format(req.pk) in request.POST else None,
                    initial={'action': Response.NONE},
                    profile=userProfile,
                    request=req,
                    prefix="response-{0}".format(req.pk),
                    )
            else:
                response_form = ResponseForm(
                    request.POST if "add_response-{0}".format(req.pk) in request.POST else None,
                    profile=userProfile,
                    request=req,
                    prefix="response-{0}".format(req.pk),
                    )

            upvote = userProfile in req.upvotes.all()
            vote_form = VoteForm(
                request.POST if "vote-{0}".format(req.pk) in request.POST else None,
                request.POST or None,
                profile=userProfile,
                request=req,
                prefix="vote-{0}",
                )

            if response_form.is_valid():
                response_form.save()
                return HttpResponseRedirect(reverse('managers:my_requests'))
            if vote_form.is_valid():
                vote_form.save()
                return HttpResponseRedirect(reverse('managers:my_requests'))

            requests_list.append((req, responses_list, response_form, upvote, vote_form))
        request_form = RequestForm(
            request.POST if "submit_request" in request.POST else None,
            profile=userProfile,
            request_type=request_type,
            prefix="request-{0}".format(request_type.pk),
            )
        if request_form.is_valid():
            request_form.save()
            return HttpResponseRedirect(reverse('managers:my_requests'))
        request_dict.append((request_type, request_form, type_manager,
                             requests_list, relevant_managers))
    return render_to_response('my_requests.html', {
        'page_name': page_name,
        'request_dict': request_dict,
        }, context_instance=RequestContext(request))
171401
public void viewAccepted(View new_view) {
        List<Address> new_mbrs=new_view.getMembers();
        if(new_mbrs != null) {
            notifyViewChange(new_view);
            members.clear();
            members.addAll(new_mbrs);
        }
		//if size is bigger than one, there are more peers in the group
		//otherwise there is only one server.
        send_message=members.size() > 1;
    }
78412
function updateRequestStatus(request) {
    if (!request || !request.id || !request.status) { return; }
    dispatcher.handleViewAction({
        data: { request: request },
        type: 'update'
    });
    return request;
}
1249154
def _view_or_add(self, uid):
        '''
        
        '''
        postinfo = MPost.get_by_uid(uid)
        if postinfo:
            self.viewinfo(postinfo)
        elif self.userinfo:
            self._to_add(uid=uid)
        else:
            self.show404()
182609
def view(name, params = {}, payload = {}, &block)
      opts = {}
      params = params.dup
      payload['keys'] = params.delete(:keys) if params[:keys]

      # Continuous feeds need to be parsed differently
      opts[:continuous] = true if params['feed'] == 'continuous'

      # Try recognising the name, otherwise assume already prepared
      view_path = name_to_view_path(name)
      req_path = CouchRest.paramify_url("#{path}/#{view_path}", params)

      if payload.empty?
        connection.get req_path, opts, &block
      else
        connection.post req_path, payload, opts, &block
      end
    end
498044
def view_on_site(self, request, content_type_id, object_id):
        
        # Look up the object, making sure it's got a get_absolute_url() function.
        try:
            content_type = ContentType.objects.get(pk=content_type_id)
            if not content_type.model_class():
                raise Http404(_("Content type %(ct_id)s object has no associated model") % {
                    'ct_id': content_type_id,
                })
            obj = content_type.get_object_for_this_type(pk=object_id)
        except (ObjectDoesNotExist, ValueError):
            raise Http404(_("Content type %(ct_id)s object %(obj_id)s doesn't exist") % {
                'ct_id': content_type_id,
                'obj_id': object_id,
            })

        try:
            get_absolute_url = obj.get_absolute_url
        except AttributeError:
            raise Http404(_("%(ct_name)s objects don't have a get_absolute_url() method") % {
                'ct_name': content_type.name,
            })
        absurl = get_absolute_url()

        return HttpResponseRedirect(absurl)
1265830
def request_view(request, request_pk):
    '''
    
    '''
    if request.is_ajax():
        if not request.user.is_authenticated():
            return HttpResponse(json.dumps(dict()),
                                content_type="application/json")

        try:
            relevant_request = Request.objects.get(pk=request_pk)
        except Request.DoesNotExist:
            return HttpResponse(json.dumps(dict()),
                                content_type="application/json")

        try:
            user_profile = UserProfile.objects.get(user=request.user)
        except UserProfile.DoesNotExist:
            return HttpResponse(json.dumps(dict()),
                                content_type="application/json")

        upvote = user_profile in relevant_request.upvotes.all()
        vote_form = VoteForm(
            request.POST if "upvote" in request.POST else None,
            profile=user_profile,
            request=relevant_request,
            )
        if vote_form.is_valid():
            vote_form.save()
            response = dict()
            response['vote_count_{pk}'.format(pk=request_pk)] = \
                relevant_request.upvotes.all().count()

            list_string = 'vote_list_{pk}'.format(pk=request_pk)
            vote_string = 'in_votes_{pk}'.format(pk=request_pk)
            count_string = 'vote_count_{pk}'.format(pk=request_pk)
            response[list_string], response[vote_string], \
                response[count_string] = build_ajax_votes(
                    relevant_request,
                    user_profile
                )
            return HttpResponse(json.dumps(response),
                                content_type="application/json")
        return HttpResponse(json.dumps(dict()),
                            content_type="application/json")

    relevant_request = get_object_or_404(Request, pk=request_pk)

    if relevant_request.private:
        if relevant_request.owner.user != request.user or \
          relevant_request.request_type.managers.filter(incumbent__user=request.user):
          return HttpResponseRedirect(
              reverse("managers:requests",
                      kwargs={"requestType": relevant_request.request_type.url_name}))

    userProfile = UserProfile.objects.get(user=request.user)
    request_responses = Response.objects.filter(request=relevant_request)
    relevant_managers = relevant_request.request_type.managers.filter(active=True)
    manager = any(i.incumbent == userProfile for i in relevant_managers)
    if manager:
        response_form = ManagerResponseForm(
            request.POST if "add_response" in request.POST else None,
            initial={'action': Response.NONE},
            profile=userProfile,
            request=relevant_request,
            )
    else:
        response_form = ResponseForm(
            request.POST if "add_response" in request.POST else None,
            profile=userProfile,
            request=relevant_request,
            prefix="response",
            )
    upvote = userProfile in relevant_request.upvotes.all()
    vote_form = VoteForm(
        request.POST if "upvote" in request.POST else None,
        profile=userProfile,
        request=relevant_request,
        )
    if response_form.is_valid():
        response_form.save()
        return HttpResponseRedirect(reverse('managers:view_request', kwargs={
            'request_pk': relevant_request.pk,
            }))
    if vote_form.is_valid():
        vote_form.save()
        return HttpResponseRedirect(reverse('managers:view_request', kwargs={
            'request_pk': relevant_request.pk,
            }))
    upvote = userProfile in relevant_request.upvotes.all()
    return render_to_response('view_request.html', {
        'page_name': "View Request",
        'relevant_request': relevant_request,
        'request_responses': request_responses,
        'upvote': upvote,
        'vote_form': vote_form,
        'response_form': response_form,
        'relevant_managers': relevant_managers,
        }, context_instance=RequestContext(request))
976671
def requests_view(request, requestType):
    '''
    
    '''
    userProfile = UserProfile.objects.get(user=request.user)
    request_type = get_object_or_404(RequestType, url_name=requestType)
    page_name = "{0} Requests".format(request_type.name.title())
    if not request_type.enabled:
        message = "{0} requests have been disabled.".format(request_type.name.title())
        return red_home(request, message)
    relevant_managers = request_type.managers.filter(active=True)
    manager = any(i.incumbent == userProfile for i in relevant_managers)
    request_form = RequestForm(
        request.POST if "submit_request" in request.POST else None,
        profile=userProfile,
        request_type=request_type,
        )
    if request_form.is_valid():
        request_form.save()
        return HttpResponseRedirect(reverse('managers:requests', kwargs={'requestType': requestType}))
    # number of requests loaded
    x = 0
    # A pseudo-dictionary, actually a list with items of form (request,
    # [request_responses_list], response_form, upvote, vote_form)
    requests_dict = list()
    requests = Request.objects.filter(request_type=request_type)
    if not request_type.managers.filter(incumbent__user=request.user):
        requests = requests.exclude(
            ~Q(owner__user=request.user), private=True,
            )
    for req in requests:
        request_responses = Response.objects.filter(request=req)
        if manager:
            response_form = ManagerResponseForm(
                request.POST if "add_response-{0}".format(req.pk) in request.POST else None,
                initial={'action': Response.NONE},
                prefix="{0}".format(req.pk),
                profile=userProfile,
                request=req,
                )
        else:
            response_form = ResponseForm(
                request.POST if "add_response-{0}".format(req.pk) in request.POST else None,
                prefix="{0}".format(req.pk),
                profile=userProfile,
                request=req,
                )
        upvote = userProfile in req.upvotes.all()
        vote_form = VoteForm(
            request.POST if "vote-{0}".format(req.pk) in request.POST else None,
            profile=userProfile,
            request=req,
            )
        if response_form.is_valid():
            response_form.save()
            return HttpResponseRedirect(reverse('managers:requests',
                                                kwargs={'requestType': requestType}))
        if vote_form.is_valid():
            vote_form.save()
            return HttpResponseRedirect(reverse('managers:requests',
                                                kwargs={'requestType': requestType}))
        requests_dict.append((req, request_responses, response_form, upvote, vote_form))
        x += 1
        if x >= settings.MAX_REQUESTS:
            break
    return render_to_response('requests.html', {
        'manager': manager,
        'request_type': request_type,
        'page_name': page_name,
        'request_form': request_form,
        'requests_dict': requests_dict,
        'relevant_managers': relevant_managers,
        }, context_instance=RequestContext(request))
384131
private boolean isVisibleAndWebDisplayable(RepositoryResource resource) {
        if (resource instanceof WebDisplayable) {
            DisplayPolicy displayPolicy = ((WebDisplayable) resource).getWebDisplayPolicy();
            return displayPolicy == DisplayPolicy.VISIBLE || displayPolicy == null;
        } else {
            return false;
        }
    }
1039222
def _api_views(self, plugin):
        
        response.content_type = 'application/json; charset=utf-8'

        if plugin not in self.plugins_list:
            abort(400, "Unknown plugin %s (available plugins: %s)" % (plugin, self.plugins_list))

        # Update the stat
        # self.__update__()

        try:
            # Get the JSON value of the stat views
            ret = self.stats.get_plugin(plugin).get_views()
        except Exception as e:
            abort(404, "Cannot get views for plugin %s (%s)" % (plugin, str(e)))
        return ret
778060
def is_available(self):
        
        if self.is_always_available:
            return True
        for viewname in self.__views__:
            if getattr(self, viewname).is_available():
                return True
        return False
203741
def file_set_visibility(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/setVisibility' % object_id, input_params, always_retry=always_retry, **kwargs)
698627
def get_views_traffic(self, per=github.GithubObject.NotSet):
        
        assert per is github.GithubObject.NotSet or (isinstance(per, (str, unicode)) and (per == "day" or per == "week")), "per must be day or week, day by default"
        url_parameters = dict()
        if per is not github.GithubObject.NotSet:
            url_parameters["per"] = per
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.url + "/traffic/views",
            parameters=url_parameters
        )
        if (isinstance(data, dict)) and ("views" in data) and (isinstance(data["views"], list)):
            data["views"] = [
                github.View.View(self._requester, headers, item, completed=True)
                for item in data["views"]
            ]
            return data