Return Subscriptions not in trial status between a certain time range.
182960
def started_during(self, year, month):
		""""""
		return self.exclude(status="trialing").filter(start__year=year, start__month=month)
256952
public Subscription endTrialAt( Subscription subscription, Date date ) {
    ParameterMap<String, String> params = new ParameterMap<String, String>();
    params.add( "trial_end", String.valueOf( date.getTime() / 1000 ) );
    return RestfulUtils.update( SubscriptionService.PATH, subscription, params, false, Subscription.class, super.httpClient );
  }
861006
def check_sync(self):
        """"""
        # If refresh interval is not specified, we should refresh every time.
        expiration = utcnow()
        refresh_td = current_app.config.get('GITHUB_REFRESH_TIMEDELTA')
        if refresh_td:
            expiration -= refresh_td
        last_sync = parse_timestamp(self.account.extra_data['last_sync'])
        return last_sync < expiration
143962
def check_user(self, todays_facts):
        """"""
        interval = self.conf_notify_interval
        if interval <= 0 or interval >= 121:
            return

        now = dt.datetime.now()
        message = None

        last_activity = todays_facts[-1] if todays_facts else None

        # update duration of current task
        if last_activity and not last_activity['end_time']:
            delta = now - last_activity['start_time']
            duration = delta.seconds /  60

            if duration and duration % interval == 0:
                message = _("Working on %s") % last_activity['name']
                self.notify_user(message)

        elif self.conf_notify_on_idle:
            #if we have no last activity, let's just calculate duration from 00:00
            if (now.minute + now.hour * 60) % interval == 0:
                self.notify_user(_("No activity"))
268380
def to_discontinuous(self):
        """"""
        collection = HourlyDiscontinuousCollection(self.header.duplicate(),
                                                   self.values, self.datetimes)
        collection._validated_a_period = True
        return collection
762634
def range_daily(start=None, stop=None, timezone='UTC', count=None):
    
    return stops(start=start, stop=stop, freq=DAILY, timezone=timezone, count=count)
1060111
def canceled_during(self, year, month):
		""""""
		return self.canceled().filter(canceled_at__year=year, canceled_at__month=month)
370738
def subscriptions(self):
        """"""
        if not hasattr(self, '_subscriptions'):
            subscriptions_resource = self.resource.subscriptions
            self._subscriptions = Subscriptions(
                subscriptions_resource, self.client)
        return self._subscriptions
300567
def routeDefault(self, request, year=None):
        """"""
        eventsView = request.GET.get('view', self.default_view)
        if eventsView in ("L", "list"):
            return self.serveUpcoming(request)
        elif eventsView in ("W", "weekly"):
            return self.serveWeek(request, year)
        else:
            return self.serveMonth(request, year)
384823
def _one(self, query):
        """"""
        try:
            result = query.one()
            if result.has_expired(self._expirations):
                raise NotFoundError
            return result
        except (NoResultFound, MultipleResultsFound):
            raise NotFoundError
107376
def get_active(slug=DEFAULT_TERMS_SLUG):
        """"""

        active_terms = cache.get('tandc.active_terms_' + slug)
        if active_terms is None:
            try:
                active_terms = TermsAndConditions.objects.filter(
                    date_active__isnull=False,
                    date_active__lte=timezone.now(),
                    slug=slug).latest('date_active')
                cache.set('tandc.active_terms_' + slug, active_terms, TERMS_CACHE_SECONDS)
            except TermsAndConditions.DoesNotExist:  # pragma: nocover
                LOGGER.error("Requested Terms and Conditions that Have Not Been Created.")
                return None

        return active_terms
1231047
def getPreSubscription(self):
		'''
		
		'''
		result = asyncResult()
		data = self._getURL("/subscriptions")
		if data.status_code == 200: #immediate success
			result.error = False
			result.is_done = True
			result.result = data.json()
		else:
			result.error = response_codes("presubscription",data.status_code)
			result.is_done = True
		result.raw_data = data.content
		result.status_code = data.status_code
		return result
643024
def _check_time_range(time_range, now):
    '''
    
    '''
    if _TIME_SUPPORTED:
        _start = dateutil_parser.parse(time_range['start'])
        _end = dateutil_parser.parse(time_range['end'])

        return bool(_start <= now <= _end)
    else:
        log.error('Dateutil is required.')
        return False
1194067
def exclude(self, data, range_obj):
        
        if isinstance(range_obj, (pd.DatetimeIndex, tuple)):
            range_obj = DateRange(range_obj[0], range_obj[-1])
        if 'date' in data.index.names:
            return data[(data.index.get_level_values('date') < range_obj.start) | (data.index.get_level_values('date') > range_obj.end)]
        elif 'date' in data.columns:
            return data[(data.date < range_obj.start) | (data.date > range_obj.end)]
        else:
            return data
19874
def filter_published(self, queryset):
        """"""
        if settings.PAGE_USE_SITE_ID:
            queryset = queryset.filter(sites=global_settings.SITE_ID)

        queryset = queryset.filter(status=self.model.PUBLISHED)

        if settings.PAGE_SHOW_START_DATE:
            queryset = queryset.filter(publication_date__lte=get_now())

        if settings.PAGE_SHOW_END_DATE:
            queryset = queryset.filter(
                Q(publication_end_date__gt=get_now()) |
                Q(publication_end_date__isnull=True)
            )

        return queryset
788549
def sync_subscriber(subscriber):
	""""""
	customer, _created = Customer.get_or_create(subscriber=subscriber)
	try:
		customer.sync_from_stripe_data(customer.api_retrieve())
		customer._sync_subscriptions()
		customer._sync_invoices()
		customer._sync_cards()
		customer._sync_charges()
	except InvalidRequestError as e:
		print("ERROR: " + str(e))
	return customer
1061539
def filter_users_by_claims(self, claims):
        """"""
        email = claims.get('email')
        if not email:
            return self.UserModel.objects.none()
        return self.UserModel.objects.filter(email__iexact=email)