当前位置: 首页>>代码示例>>Python>>正文


Python Week.thisweek方法代码示例

本文整理汇总了Python中isoweek.Week.thisweek方法的典型用法代码示例。如果您正苦于以下问题:Python Week.thisweek方法的具体用法?Python Week.thisweek怎么用?Python Week.thisweek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在isoweek.Week的用法示例。


在下文中一共展示了Week.thisweek方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_menus_list

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
    def get_menus_list(self):
        r = requests.get("https://sites.google.com/site/fedorestbe/menu-fr/menu-noga-fr")

        soup = BeautifulSoup(r.content, "lxml")

        current_week = Week.thisweek().week
        current_year = Week.thisweek().year

        content = ""

        content += "Voici les menus disponibles concoctes par les chefs Fedorest. Nous sommes en semaine {}-{} : \n".format(current_year, current_week)

        link_cells = soup.find_all("td", {"class": "td-file"})
        regex = r"noga_fr_(\d+)_(\d+)\.pdf"

        for cell in link_cells:
            links = cell.find_all("a")
            for link in links:
                url = link.get("href")
                matches = re.findall(regex, url)
                if matches:
                    (week, year) = matches[0]
                    content += "* ["+year + "-"+week + "](" + GOOGLE_SITE_BASE + url + ")\n"

        return content
开发者ID:Juljan,项目名称:python-zulip-api,代码行数:27,代码来源:fedorest.py

示例2: handle_noargs

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
    def handle_noargs(self, **options):
        translation.activate('fr')

        logging.debug('Command in progress')

        week_limit = Week.withdate(Week.thisweek().day(settings.VALIDATING_DAY_OF_WEEK) + relativedelta(days=settings.DELAY_BETWEEN_DEFINITON_N_DELIVERY))

        # first changed the status of expired deliveries
        deliveries_canceled = models.Delivery.objects.filter(date__lt=week_limit, status='w', subscription__enabled=True)
        for delivery in deliveries_canceled:
            delivery.status = 'e'
            delivery.save()
            logging.debug('delivery %d expired' % delivery.id)

        # secondly, get all the deliveries with a date higher or equal to J+9 and lesser than J+9+7 with a waiting status and a subscription which accepts direct debit.
        deliveries = models.Delivery.objects.filter(date__gte=week_limit, date__lt=week_limit+1, status='w', subscription__direct_debit=True, subscription__enabled=True)

        for delivery in deliveries:
            delivery.status = 'p'
            try:
                delivery.save()
            except ValueError as e:
                logging.debug('delivery %d not payed' % delivery.id)
            else:
                logging.debug('delivery %d payed' % delivery.id)

        translation.deactivate()
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:29,代码来源:directdebits.py

示例3: __init__

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     start = self.fields['start']
     cw = Week.thisweek()
     choices = [str(w + cw.week) for w in Week.weeks_of_year(cw.year)]
     start.choices = zip(choices, choices)
     start.initial = cw+1
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:9,代码来源:__init__.py

示例4: validate_period

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
def validate_period(period, first_date):
    '''
    make sure only period is  between first_date and today
    '''  
    today = datetime.now().strftime('%Y%m%d')

    # Day yyyyMMdd
    if type_of_period(period) == 'day':
        if period >= first_date and period <= today:
            return True
    
    # Week yyyy-Www
    elif type_of_period(period) == 'week':
        this_week = Week.thisweek()
        period_week = Week.fromstring(period)
        first_date_week = Week.withdate(datetime.strptime(first_date, '%Y%m%d'))
        if period_week >= first_date_week and period_week <= this_week:
            return True

    # Month yyyyMM
    elif type_of_period(period) == 'month':
        this_month       = datetime.now().strftime('%Y%m')
        period_month     = period[0:6]
        first_date_month = first_date[0:6]
        if period_month >= first_date_month and period_month <= this_month:
            return True
        
    return False
开发者ID:JayWayChen,项目名称:wkcycle,代码行数:30,代码来源:utils.py

示例5: week_display

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
def week_display():
    # Default view is the current week. 
    if session.week is None:
        session.week = Week.thisweek()[1]
        session.year = date.today().year

    week = session.week
    year = session.year

    # some years end in week 53, others in week 52
    lastweekofyear = Week.last_week_of_year(year)[1]
    # If it is the last week of the year, fix forward button
    if lastweekofyear == week:
        forward = {"week":1,"year":year + 1}
    else:
        forward = {"week":week + 1,"year":year}
    # If it is the first week of the year, fix back button
    if week == 1:
        back = {"week":Week.last_week_of_year(year - 1)[1],"year":year - 1}
    else:
        back = {"week":week - 1,"year":year}

    # Our startdate will be current week, beginning with monday
    # set remaining sessions to new values and move on
    session.startday = Week(year, week).monday()
    session.back = back
    session.forward = forward
    session.week = week
    session.year = year 
开发者ID:rikardq,项目名称:rimi,代码行数:31,代码来源:instructor.py

示例6: handle_noargs

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
    def handle_noargs(self, **options):
        translation.activate('fr')

        week_limit = Week.withdate(Week.thisweek().day(settings.VALIDATING_DAY_OF_WEEK) + relativedelta(days=settings.DELAY_BETWEEN_DEFINITON_N_DELIVERY))
        deliveries = models.Delivery.objects.filter(date__lte=week_limit, status='P', subscription__enabled=True).order_by('subscription__customer__account__email')
        count=0

        for delivery in deliveries:
            logger_delivery = logging.getLogger('[%d]' % delivery.id)

            subscription = delivery.subscription
            customer = subscription.customer

            logger_delivery.info(delivery.__unicode__())

            for content in delivery.content_set.all():
                __extent = content.extent

                logger_content = logging.getLogger('[%d] [%20s] [%c] [%3s%%]' % (delivery.id, content.product.name[:20], '*' if content.customized else ' ', __extent))

                for contentproduct in content.contentproduct_set.all():
                    logger_content.info('%d x %20s (%4d) %s' % (contentproduct.quantity, contentproduct.product.name[:20], contentproduct.product.id, contentproduct.product.main_price.supplier_product_url))
                    if options['browse']:
                        webbrowser.open(contentproduct.product.main_price.supplier_product_url)
                        count += 1
                        if count >= options['pages']:
                            count = 0
                            try:
                                input()
                            except KeyboardInterrupt:
                                print('Interrupted'); sys.exit()

            logger_delivery.info('')

        translation.deactivate()
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:37,代码来源:generate_order.py

示例7: test_constructors

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
    def test_constructors(self):
        w = Week(2011,1)
        self.assertTrue(w)
        self.assertEqual(str(w), "2011W01")

        w = Week(2011,0)
        self.assertEqual(str(w), "2010W52")
        w = Week(2011,-1)
        self.assertEqual(str(w), "2010W51")

        w = Week(2011,52)
        self.assertEqual(str(w), "2011W52")
        w = Week(2011,53)
        self.assertEqual(str(w), "2012W01")
        w = Week(2011,54)
        self.assertEqual(str(w), "2012W02")

        w = Week(2009,51)
        self.assertEqual(str(w), "2009W51")
        w = Week(2009,52)
        self.assertEqual(str(w), "2009W52")
        w = Week(2009,53)
        self.assertEqual(str(w), "2010W01")
        w = Week(2009,54)
        self.assertEqual(str(w), "2010W02")

        w = Week.thisweek()
        self.assertTrue(w)

        w = Week.fromordinal(1)
        self.assertEqual(str(w), "0001W01")
        w = Week.fromordinal(2)
        self.assertEqual(str(w), "0001W02")
        w = Week.fromordinal(521723)
        self.assertEqual(str(w), "9999W52")

        w = Week.fromstring("2011W01")
        self.assertEqual(str(w), "2011W01")
        w = Week.fromstring("2011-W01")
        self.assertEqual(str(w), "2011W01")

        from datetime import date
        w = Week.withdate(date(2011, 5, 17))
        self.assertEqual(str(w), "2011W20")

        self.assertEqual(Week.last_week_of_year(2009), Week(2009, 52))
        self.assertEqual(Week.last_week_of_year(2010), Week(2010, 52))
        self.assertEqual(Week.last_week_of_year(2011), Week(2011, 52))
        self.assertEqual(Week.last_week_of_year(9999), Week(9999, 52))

        self.assertRaises(ValueError, lambda: Week(0, 0))
        self.assertRaises(ValueError, lambda: Week.fromstring("0000W00"))
        self.assertRaises(ValueError, lambda: Week.fromstring("foo"))
        self.assertRaises(ValueError, lambda: Week.fromordinal(-1))
        self.assertRaises(ValueError, lambda: Week.fromordinal(0))
        self.assertRaises(ValueError, lambda: Week.fromordinal(521724))
        self.assertRaises(ValueError, lambda: Week.last_week_of_year(0))
        self.assertRaises(ValueError, lambda: Week.last_week_of_year(10000))
开发者ID:mcgarryfashion,项目名称:isoweek,代码行数:60,代码来源:test_isoweek.py

示例8: home

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
def home(request, year=None, week=None):
    if not year or not week:
        # use previous week by default
        week = Week.thisweek() - 1
    else:
        week = Week(int(year), int(week))

    date_range = get_date_range(week)

    # absolute worst titles
    worst_titles = NewsItem.objects.filter(published__range=date_range, score__isnull=False).order_by('-score')[:5]

    # worst sites on average
    site_avg = Site.objects.filter(
        newsitems__published__range=date_range,
        newsitems__score__isnull=False
        ).annotate(
        score=Avg('newsitems__score')
        ).order_by('-score')[:5]

    # biggest percentage of bad titles
    sites = Site.objects.filter(
        newsitems__published__range=date_range,
        newsitems__score__isnull=False
        ).annotate(
        bad=Sum(Case(When(newsitems__score__gt=1.0, then=1), output_field=IntegerField())),
        total=Count('newsitems__score'),
        )

    percentages = []

    # calculate percentages
    for site in sites:
        bad = float(site.bad if site.bad else 0)
        total = float(site.total if site.total else 0)

        percentage = int((bad/total)*100)

        percentages.append((percentage, site))

    # sort by percentage and take top 5
    percentages = list(reversed(sorted(percentages, key=lambda x: x[0])))[:5]

    context = {
        'worst_titles': worst_titles,
        'site_avg': site_avg,
        'bad_percentages': percentages,
        'date_range': {
            'week': week,
            'start': date_range[0].date(),
            'end': date_range[1].date(),
        }
    }

    return render(request, 'home.html', context)
开发者ID:carbn,项目名称:huonot-uutiset,代码行数:57,代码来源:views.py

示例9: __init__

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        cw = Week.withdate(Week.thisweek().sunday() + relativedelta(days=9))
        start = self.fields['start']
        start_choices = [str(w + cw.week - 1) for w in Week.weeks_of_year(cw.year)]
        start_date_choices = ['%s (%s %s)' % ((w + cw.week - 1).day(settings.DELIVERY_DAY_OF_WEEK).strftime('%d-%m-%Y'), _('Week'), (w + cw.week - 1).week) for w in Week.weeks_of_year(cw.year)]
        start.choices = zip(start_choices, start_date_choices)
        start.initial = cw

        for field in ['size', 'frequency', 'duration', 'start']:
            self.fields[field].widget.attrs['class'] = 'slidebar-select'

        for field in ['criterias', 'receive_only_once']:
            self.fields[field].widget.attrs['class'] = 'checkbox-select'

        for field in ['carrier']:
            self.fields[field].widget.attrs['class'] = 'radio-select'
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:20,代码来源:createall.py

示例10: handle_noargs

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
    def handle_noargs(self, **options):
        translation.activate('fr')
        logging.debug('Command in progress')

        self.print_interactive_usage()

        if options['test']:
            logging.info('[TEST MODE enabled]')
            logging.info('')

        week_limit = Week.withdate(Week.thisweek().day(settings.VALIDATING_DAY_OF_WEEK) + relativedelta(days=settings.DELAY_BETWEEN_DEFINITON_N_DELIVERY))
        deliveries = models.Delivery.objects.filter(date__lte=week_limit, status='p', subscription__enabled=True)

        logging.info('Number of deliveries to fullfill: %d' % deliveries.count())

        for delivery in deliveries:
            logger_delivery = logging.getLogger('[delivery %d]' % delivery.id)

            logger_delivery.info('')
            logger_delivery.info('Process the delivery: %s' % delivery.__unicode__())
            logger_delivery.info('')

            subscription = delivery.subscription
            subscription_weight = subscription.size.weight - subscription.size.weight*settings.PACKAGING_WEIGHT_RATE/100
            subscription_price = subscription.price().price
            carrier = subscription.carrier
            weight_level = carrier.carrierlevel_set.filter(weight__gte=subscription.size.weight)
            if weight_level:
                logger_delivery.info('weight level:\t\t%s kg (%s €)' % (weight_level[0].weight, weight_level[0].price))
                subscription_price -= weight_level[0].price

            logger_delivery.info('carrier:\t\t%s' % carrier.name)
            logger_delivery.info('subscription weight:\t%s kg' % subscription_weight)
            logger_delivery.info('subscription price:\t%s € (%s €)' % (subscription_price, subscription.price().price))
            logger_delivery.info('')

            for extent in subscription.extent_set.all():
                __extent = extent.extent

                logger_extent = logging.getLogger('[delivery %d] [%s] [%s%%]' % (delivery.id, extent.product.name, __extent))


                logger_extent.debug('meta-product: %s, extent: %s' % (extent.product.name, __extent))

                if extent.customized:
                    logger_extent = logging.getLogger('[delivery %d] [%s] [%s%%] [custom]' % (delivery.id, extent.product.name, __extent))

                    logger_extent.info('start fullfilling the delivery cart with a custom content')

                    logger_extent.info('create custom content object')
                    content = delivery.content_set.create(product=extent.product, extent=extent.extent, customized=extent.customized) if not options['test'] else None
                    extent_content = extent.extentcontent_set.get()

                    for ecp in extent_content.extentcontentproduct_set.all():
                        logger_extent.info('+ %d x %30s\t\t(%d,\t%s€,\t%sg)' % (ecp.quantity, ecp.product.name[:30], ecp.product.id, ecp.product.price().__unicode__(), ecp.product.weight))
                        if not options['test']:
                            content.contentproduct_set.create(product=ecp.product, quantity=ecp.quantity)

                    continue

                def get_product_products(product):
                    __products = []
                    for child in product.products_children.all():
                        __products += get_product_products(child)
                    __products += product.product_product.filter(status='p').all()
                    return __products

                products = get_product_products(extent.product)
                nbr_items = len(products)

                prices = [p.main_price.get_after_tax_price_with_fee() if carrier.apply_suppliers_fee else p.main_price.get_after_tax_price() for p in products]
                weights = [int(p.weight or settings.DEFAULT_WEIGHT) for p in products]

                criterias = []
                if subscription.criterias.all():
                    for p in products:
                        __filter = p.criterias
                        for c in subscription.criterias.filter(enabled=True).all():
                            __filter = __filter.filter(id=c.id)
                        criterias.append(len(__filter.all()))
                else:
                    criterias = [0] * nbr_items

                total_price = round(subscription_price*__extent/100, 2)
                total_weight = round(subscription_weight*__extent/100*1000, 2)
                total_criteria = round(sum(criterias), 2)

                creator.create("Fitness", base.Fitness, weights=(-1.0,-1.0,-1.0,-1.0,))
                creator.create("Individual", list, fitness=creator.Fitness)

                toolbox = base.Toolbox()

                if options['zero']:
                    toolbox.register("quantity_item", lambda: options['min_quantity'])
                else:
                    toolbox.register("quantity_item", random.randint, options['min_quantity'], options['max_quantity'])

                toolbox.register("individual", tools.initRepeat, creator.Individual,
                                 toolbox.quantity_item, nbr_items)
                toolbox.register("population", tools.initRepeat, list, toolbox.individual)
#.........这里部分代码省略.........
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:103,代码来源:interactive_fullfillcarts.py

示例11: get_current_monday

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
def get_current_monday(timestamp=False):
    monday = datetime.combine(Week.thisweek().monday(), dtime.min)
    if timestamp:
        return time.mktime(monday.timetuple())
    return monday
开发者ID:000fan000,项目名称:code,代码行数:7,代码来源:date.py

示例12: get_last_sunday

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
def get_last_sunday(timestamp=False):
    sunday = datetime.combine((Week.thisweek() - 1).sunday(), dtime.min)
    if timestamp:
        return time.mktime(sunday.timetuple())
    return sunday
开发者ID:000fan000,项目名称:code,代码行数:7,代码来源:date.py

示例13: handle_noargs

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
    def handle_noargs(self, **options):
        translation.activate('fr')

        logging.debug('Command in progress')

        pop_size = 50
        max_gen = 50
        lambda_algo = 100
        cxpb = .7
        mutpb = .2
        min_quantity = 0
        max_quantity = 2
        margin = .1
        zero = True
        debug = False

        if debug: logging.debug('DEBUG MODE')

        week_limit = Week.withdate(Week.thisweek().day(setting.VALIDATING_DAY_OF_WEEK) + relativedelta(days=settings.DELAY_BETWEEN_DEFINITON_N_DELIVERY))
        deliveries = models.Delivery.objects.filter(date__lte=week_limit, status='p', subscription__enabled=True)
        for delivery in deliveries:
            logging.debug(delivery.__unicode__())

            subscription = delivery.subscription
            subscription_weight = subscription.size.weight - subscription.size.weight*settings.PACKAGING_WEIGHT_RATE/100
            subscription_price = subscription.price().price
            carrier = subscription.carrier
            weight_level = carrier.carrierlevel_set.filter(weight__gte=subscription.size.weight)
            if weight_level:
                logging.debug('weight_level: %s kg (%s €)' % (weight_level[0].weight, weight_level[0].price))
                subscription_price -= weight_level[0].price

            logging.debug('carrier: %s' % carrier.name)
            logging.debug('subscription_weight: %s kg' % subscription_weight)
            logging.debug('subscription_price: %s € (%s €)' % (subscription_price, subscription.price().price))

            for extent in subscription.extent_set.all():
                __extent = extent.extent

                logging.debug('meta-product: %s, extent: %s' % (extent.product.name, __extent))

                if extent.customized:
                    logging.debug("start fullfilling the delivery cart with a custom content")

                    logging.debug("create custom content object")
                    content = delivery.content_set.create(product=extent.product, extent=extent.extent, customized=extent.customized) if not debug else None
                    extent_content = extent.extentcontent_set.get()

                    for ecp in extent_content.extentcontentproduct_set.all():
                        logging.debug("add product %s (%d) with a quantity %d (price: %s, weight: %s)" % (ecp.product.name, ecp.product.id, ecp.quantity, ecp.product.price().__unicode__(), ecp.product.weight))
                        if not debug:
                            content.contentproduct_set.create(product=ecp.product, quantity=ecp.quantity)

                    continue

                def get_product_products(product):
                    __products = []
                    for child in product.products_children.all():
                        __products += get_product_products(child)
                    __products += product.product_product.filter(status='p').all()
                    return __products

                products = get_product_products(extent.product)
                nbr_items = len(products)

                prices = [p.main_price.get_after_tax_price_with_fee() if carrier.apply_suppliers_fee else p.main_price.get_after_tax_price() for p in products]
                weights = [int(p.weight) for p in products]

                criterias = []
                if subscription.criterias.all():
                    for p in products:
                        __filter = p.criterias
                        for c in subscription.criterias.filter(enabled=True).all():
                            __filter = __filter.filter(id=c.id)
                        criterias.append(len(__filter.all()))
                else:
                    criterias = [0] * nbr_items

                total_price = round(subscription_price*__extent/100, 2)
                total_weight = round(subscription_weight*__extent/100*1000, 2)
                total_criteria = round(sum(criterias), 2)

                from deap import algorithms, base, creator, tools

                pareto = tools.selNSGA2
                # pareto = tools.selSPEA2
                algo = algorithms.eaMuPlusLambda
                # algo = algorithms.eaMuCommaLambda

                creator.create("Fitness", base.Fitness, weights=(-1.0,-1.0,-1.0,-1.0,))
                creator.create("Individual", list, fitness=creator.Fitness)

                toolbox = base.Toolbox()

                if zero:
                    toolbox.register("quantity_item", lambda: min_quantity)
                else:
                    toolbox.register("quantity_item", random.randint, min_quantity, max_quantity)

                toolbox.register("individual", tools.initRepeat, creator.Individual,
#.........这里部分代码省略.........
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:103,代码来源:fullfillcarts.py

示例14: page_urls

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
def page_urls(period):
    '''
    return the next period.
    e.g. next period of 20140824 is 20140825
         next period of 201408   is 201409
         next period of 2014-W34 is 2014-W35
    '''

    page = dict()

    # 'Day', 'Week', 'Month' link to the current day/week/month 
    today             = datetime.now().strftime('%Y%m%d')
    this_week         = Week.thisweek().isoformat()[:4] + '-' +  Week.thisweek().isoformat()[4:]
    this_month        = datetime.now().strftime('%Y%m')
    page['day_url']   = url_for('views.leaderboard_period', period=today)
    page['week_url']  = url_for('views.leaderboard_period', period=this_week)
    page['month_url'] = url_for('views.leaderboard_period', period=this_month)

    
    if type_of_period(period) == 'day':
        # title 
        today             = datetime.strptime(period, '%Y%m%d')
        page['title']     = custom_strftime(today, '%a, %B {S} %Y')

        # 'prev' and 'next' links
        t                 = time.strptime(period, '%Y%m%d')
        today             = date(t.tm_year, t.tm_mon, t.tm_mday)
        nextday           = today + timedelta(1)
        prevday           = today + timedelta(-1)
        page['next_url']  = url_for('views.leaderboard_period', period=nextday.strftime('%Y%m%d'))
        page['prev_url']  = url_for('views.leaderboard_period', period=prevday.strftime('%Y%m%d'))
      
        return page
    
    elif type_of_period(period) == 'week':
        
        # title 
        page['title']     = datetime.strptime(period + '1', '%Y-W%W%w').strftime('Week %W, %Y')

        # 'prev' and 'next' links

        # begin_of_next_week = time.strptime('201435 1', '%Y%W %w')
        # use isoweek instead strptime('%W') since isoweek starts from week 1 
        # while strptime('%W') returns week number starting from week 0
        thisweek = Week.fromstring(period)
        nextweek = thisweek + 1
        # ISO 8610 format is "YYYYWww" while Moves API takes "YYYY-Www"
        page['next_url'] = url_for('views.leaderboard_period', period=nextweek.isoformat()[:4] + '-' + nextweek.isoformat()[4:])
        # next_text = 'Week ' + str(nextweek.week) + ', ' + str(nextweek.year)
        prevweek = thisweek -1
        page['prev_url'] = url_for('views.leaderboard_period', period=prevweek.isoformat()[:4] + '-' + prevweek.isoformat()[4:])
        # prev_text = 'Week ' + str(prevweek.week) + ', ' + str(prevweek.year)

    elif type_of_period(period) == 'month':

        #title
        page['title'] = datetime.strptime(period, '%Y%m').strftime('%B %Y')

        # 'prev' and 'next' links
        t = time.strptime(period,'%Y%m')
        thismonth = date(t.tm_year, t.tm_mon, 1)
        nextmonth = add_months(thismonth, 1)
        prevmonth = add_months(thismonth, -1)
        page['next_url'] = url_for('views.leaderboard_period', period=nextmonth.strftime('%Y%m'))
        page['prev_url'] = url_for('views.leaderboard_period', period=prevmonth.strftime('%Y%m'))
      
    return page
开发者ID:JayWayChen,项目名称:wkcycle,代码行数:69,代码来源:utils.py

示例15: _

# 需要导入模块: from isoweek import Week [as 别名]
# 或者: from isoweek.Week import thisweek [as 别名]
from mailbox import models as mm

FREQUENCY_CHOICES = (
    (1, _('Once a week')),
    (2, _('Every two weeks')),
    (3, _('Every three weeks')),
    (4, _('Once a month (4 weeks)')),
    (8, _('Every two months (8 weeks)')),
    (13, _('Once a quarter (13 weeks)')),
    (26, _('Every 6 months (26 weeks)')),
)

FREQUENCY_DEFAULT = 2

__weeks = []
for y in range(settings.START_YEAR, Week.thisweek().year+2): __weeks += Week.weeks_of_year(y)
WEEKS_CHOICES = [(str(w), '%s (%s %s)' % (w.day(settings.DELIVERY_DAY_OF_WEEK).strftime('%d-%m-%Y'), _('Week'), w.week)) for w in __weeks]

class Thematic(models.Model):
    name = models.CharField(_('name'), max_length=100)
    body = models.TextField(_('body'), blank=True)
    size = models.ForeignKey('Size', verbose_name=_('size'), null=True, blank=True)
    locked_size = models.BooleanField(_('locked size'), default=False)
    carrier = models.ForeignKey('Carrier', verbose_name=_('carrier'), null=True, blank=True)
    locked_carrier = models.BooleanField(_('locked carrier'), default=False)
    receive_only_once = models.BooleanField(_('receive only once'), default=False)
    locked_receive_only_once = models.BooleanField(_('locked receive only once'), default=False)
    frequency = models.PositiveIntegerField(_('frequency'), max_length=2, choices=FREQUENCY_CHOICES, help_text=_('Delivery made sure Tuesday'), null=True, blank=True)
    locked_frequency = models.BooleanField(_('locked frequency'), default=False)
    start_duration = models.CharField(_('start duration'), max_length=7, choices=WEEKS_CHOICES,
                                      help_text=_('Here is the beginnig week of the duration.'),
开发者ID:vegeclic,项目名称:django-regularcom,代码行数:33,代码来源:models.py


注:本文中的isoweek.Week.thisweek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。