本文整理汇总了Python中remo.base.utils.number2month函数的典型用法代码示例。如果您正苦于以下问题:Python number2month函数的具体用法?Python number2month怎么用?Python number2month使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了number2month函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_reports_for_year
def get_reports_for_year(user, start_year, end_year=None,
allow_empty=False, private=True):
"""Return a list of reports for year."""
reports_list = {}
tmp_date = datetime.today()
up = user.userprofile
today = datetime(year=tmp_date.year, month=tmp_date.month, day=1)
date_joined = up.date_joined_program
tmp_date = go_fwd_n_months(date_joined)
month_first_report = datetime(year=tmp_date.year,
day=1, month=tmp_date.month)
if not end_year:
end_year = start_year
for year in range(max(start_year, date_joined.year), end_year+1):
reports = user.reports.filter(month__year=year)
if (reports.count() == 0 and private == True):
reports_list[year] = None
continue
else:
reports_list[year] = []
for month in range(1, 13):
month_details = {'name': number2month(month, full_name=False),
'fullname': number2month(month, full_name=True)}
if reports.filter(month__month=month).exists():
report = reports.get(month__month=month)
month_details['report'] = report
month_details['class'] = 'exists'
month_details['link'] = get_report_view_url(report)
else:
month_details['report'] = None
date = datetime(year=year, month=month, day=1)
if (private or month_first_report > date or date >= today):
month_details['class'] = 'unavailable'
month_details['link'] = '#'
else:
month_details['class'] = 'editable'
link = reverse('reports_edit_report',
kwargs={'display_name': up.display_name,
'year': year,
'month': month_details['fullname']})
month_details['link'] = link
reports_list[year].append(month_details)
return reports_list
开发者ID:stephendonner,项目名称:remo,代码行数:51,代码来源:utils.py
示例2: get_reports_for_year
def get_reports_for_year(user, start_year, end_year=None, allow_empty=False,
permission=REPORTS_PERMISSION_LEVEL['anonymous']):
"""Return a list of reports for year."""
reports_list = {}
tmp_date = datetime.today()
up = user.userprofile
today = datetime(year=tmp_date.year, month=tmp_date.month, day=1)
date_joined = up.date_joined_program
tmp_date = go_fwd_n_months(date_joined)
month_first_report = datetime(year=tmp_date.year,
day=1, month=tmp_date.month)
if not end_year:
end_year = start_year
for year in range(max(start_year, date_joined.year), end_year+1):
reports = user.reports.filter(month__year=year)
reports_list[year] = []
for month in range(1, 13):
month = datetime(year=year, month=month, day=1)
month_details = {'name': number2month(month.month,
full_name=False),
'fullname': number2month(month.month,
full_name=True)}
if (reports.filter(month=month).exists() and
((permission > 1 and month == today) or (month < today))):
report = reports.get(month=month)
month_details['report'] = report
month_details['class'] = 'exists'
month_details['link'] = get_report_view_url(report)
else:
month_details['report'] = None
if (permission < 3 or month_first_report > month or
month > today):
month_details['class'] = 'unavailable'
month_details['link'] = '#'
else:
month_details['class'] = 'editable'
link = reverse('reports_edit_report',
kwargs={'display_name': up.display_name,
'year': year,
'month': month_details['fullname']})
month_details['link'] = link
reports_list[year].append(month_details)
return reports_list
开发者ID:bensternthal,项目名称:remo,代码行数:50,代码来源:utils.py
示例3: handle
def handle(self, *args, **options):
"""Prepares a list of reps to be notified and the required
template variables.
"""
date = go_back_n_months(datetime.today(), 1)
rep_group = Group.objects.get(name='Rep')
reps = (rep_group.user_set
.exclude(userprofile__registration_complete=False)
.exclude(reports__month__year=date.year,
reports__month__month=date.month))
reps_without_report = reps.values_list('id', flat=True)
month = number2month(date.month)
subject = self.SUBJECT % month
data = {'year': date.year, 'month': month}
if options['dry_run']:
email_reps = reps.values_list('email', flat=True)
for recipient in email_reps:
msg = 'Second notification sent to %s' % recipient
print(msg)
else:
send_remo_mail(reps_without_report, subject,
self.EMAIL_TEMPLATE, data)
开发者ID:prameet-jain,项目名称:remo,代码行数:25,代码来源:send_second_report_notification.py
示例4: _get_url_args
def _get_url_args(self):
args = [self.user.userprofile.display_name,
self.report_date.year,
utils.number2month(self.report_date.month),
self.report_date.day,
self.id]
return args
开发者ID:Josespaul,项目名称:remo,代码行数:7,代码来源:models.py
示例5: get_comment_delete_url
def get_comment_delete_url(obj):
"""Return the delete url of a comment."""
up = obj.report.user.userprofile
month_name = number2month(obj.report.month.month)
return reverse('reports_delete_report_comment',
kwargs={'display_name': up.display_name,
'year': obj.report.month.year,
'month': month_name,
'comment_id': obj.id})
开发者ID:hoosteeno,项目名称:remo,代码行数:9,代码来源:helpers.py
示例6: handle
def handle(self, *args, **options):
"""Prepares a list of reps to be notified and the required
template variables.
"""
rep_group = Group.objects.get(name="Rep")
reps = rep_group.user_set.exclude(userprofile__registration_complete=False)
date = go_back_n_months(datetime.datetime.today(), 1)
data = {"year": date.year, "month": number2month(date.month)}
send_remo_mail(reps, self.SUBJECT, self.EMAIL_TEMPLATE, data)
开发者ID:stephendonner,项目名称:remo,代码行数:11,代码来源:send_first_report_notification.py
示例7: test_invalid_date
def test_invalid_date(self, mocked_now_date, mocked_waffle_switch):
mocked_waffle_switch.return_value = False
UserFactory.create(userprofile__is_rotm_nominee=True)
UserFactory.create(userprofile__is_rotm_nominee=True)
UserFactory.create(username='remobot')
mocked_now_date.return_value = datetime(now().year, now().month, 5)
poll_name = ('Rep of the month for {0}'.format(
number2month(now().month)))
create_rotm_poll()
poll = Poll.objects.filter(name=poll_name)
ok_(not poll.exists())
开发者ID:Azeez09,项目名称:remo,代码行数:13,代码来源:test_tasks.py
示例8: get_comment_delete_url
def get_comment_delete_url(obj):
"""Return the delete url of a comment."""
up = obj.user.userprofile
month_name = number2month(obj.report.month.month)
return reverse(
"reports_delete_report_comment",
kwargs={
"display_name": up.display_name,
"year": obj.report.month.year,
"month": month_name,
"comment_id": obj.id,
},
)
开发者ID:shollmann,项目名称:remo,代码行数:13,代码来源:helpers.py
示例9: handle
def handle(self, *args, **options):
"""Prepares a list of reps to be notified and the required
template variables.
"""
rep_group = Group.objects.get(name='Rep')
reps = (rep_group.user_set
.exclude(userprofile__registration_complete=False)
.values_list('id', flat=True))
date = go_back_n_months(datetime.datetime.today(), 1)
month = number2month(date.month)
subject = self.SUBJECT % month
data = {'year': date.year, 'month': month}
send_remo_mail(reps, subject, self.EMAIL_TEMPLATE, data)
开发者ID:caseybecking,项目名称:remo,代码行数:15,代码来源:send_first_report_notification.py
示例10: test_nominate_notification_base
def test_nominate_notification_base(self, mocked_date, mail_mock):
UserFactory.create(groups=['Mentor'])
subject = 'Nominate Rep of the month'
mentor_alias = settings.REPS_MENTORS_LIST
mocked_date.return_value = datetime(now().year, now().month, 1)
send_rotm_nomination_reminder()
ok_(mail_mock.called)
eq_(mail_mock.call_count, 1)
expected_call_list = [call(recipients_list=[mentor_alias],
subject=subject,
data={'month': number2month(now().month)},
email_template=ANY)]
eq_(mail_mock.call_args_list, expected_call_list)
开发者ID:Azeez09,项目名称:remo,代码行数:15,代码来源:test_tasks.py
示例11: send_rotm_nomination_reminder
def send_rotm_nomination_reminder():
""" Send an email reminder to all mentors.
The first day of each month, the mentor group receives an email reminder
in order to nominate Reps for the Rep of the month voting.
"""
now_date = now().date()
if now_date.day == ROTM_REMINDER_DAY:
data = {'month': number2month(now_date.month)}
subject = 'Nominate Rep of the month'
template = 'emails/mentors_rotm_reminder.txt'
send_remo_mail(subject=subject,
email_template=template,
recipients_list=[settings.REPS_MENTORS_LIST],
data=data)
开发者ID:abshetewy,项目名称:remo,代码行数:16,代码来源:tasks.py
示例12: handle
def handle(self, *args, **options):
"""Prepares a list of reps to be notified and the required
template variables.
"""
rep_group = Group.objects.get(name='Rep')
reps = rep_group.user_set.exclude(
userprofile__registration_complete=False)
date = go_back_n_months(datetime.datetime.today(), 1)
reps_without_report = reps.exclude(reports__month__year=date.year,
reports__month__month=date.month)
data = {'year': date.year, 'month': number2month(date.month)}
send_remo_mail(reps_without_report, self.SUBJECT,
self.EMAIL_TEMPLATE, data)
开发者ID:stephendonner,项目名称:remo,代码行数:16,代码来源:send_second_report_notification.py
示例13: current_report
def current_report(request, edit=False):
display_name = request.user.userprofile.display_name
previous_month = utils.go_back_n_months(datetime.date.today(),
first_day=True)
month_name = utils.number2month(previous_month.month)
report = utils.get_object_or_none(
Report, user__userprofile__display_name=display_name,
month=previous_month)
view = 'reports_view_report'
if edit or not report:
view = 'reports_edit_report'
redirect_url = reverse(view, kwargs={'display_name': display_name,
'year': previous_month.year,
'month': month_name})
return redirect(redirect_url)
开发者ID:craigcook,项目名称:remo,代码行数:17,代码来源:views.py
示例14: handle
def handle(self, *args, **options):
"""Prepares a list of reps to be notified and the required
template variables.
"""
rep_group = Group.objects.get(name="Rep")
reps = rep_group.user_set.exclude(userprofile__registration_complete=False)
date = go_back_n_months(datetime.datetime.today(), 2)
reps_without_report = reps.exclude(reports__month__year=date.year, reports__month__month=date.month)
mentors = [rep.userprofile.mentor.id for rep in reps_without_report]
month = number2month(date.month)
subject = self.SUBJECT % month
data = {"year": date.year, "month": month, "reps_without_report": reps_without_report}
send_remo_mail(mentors, subject, self.EMAIL_TEMPLATE, data)
开发者ID:rbillings,项目名称:remo,代码行数:18,代码来源:send_mentor_report_notification.py
示例15: test_base
def test_base(self, mocked_now_date):
nominee_1 = UserFactory.create(userprofile__is_rotm_nominee=True)
nominee_2 = UserFactory.create(userprofile__is_rotm_nominee=True)
UserFactory.create(username='remobot')
mocked_now_date.return_value = datetime(now().year, now().month, 11)
poll_name = ('Rep of the month for {0}'.format(
number2month(now().month)))
create_rotm_poll()
poll = Poll.objects.filter(name=poll_name)
range_poll = RangePoll.objects.get(poll=poll)
range_poll_choices = RangePollChoice.objects.filter(
range_poll=range_poll)
ok_(poll.exists())
eq_(poll.count(), 1)
eq_(set([choice.nominee for choice in range_poll_choices]),
set([nominee_1, nominee_2]))
开发者ID:Azeez09,项目名称:remo,代码行数:19,代码来源:test_tasks.py
示例16: send_rotm_nomination_reminder
def send_rotm_nomination_reminder():
""" Send an email reminder to all mentors.
The first day of each month, the mentor group receives an email reminder
in order to nominate Reps for the Rep of the month voting.
"""
now_date = now().date()
if (now_date.day == ROTM_REMINDER_DAY or
waffle.switch_is_active('enable_rotm_tasks')):
data = {'month': number2month(now_date.month)}
subject = 'Nominate Rep of the month'
template = 'emails/mentors_rotm_reminder.jinja'
send_remo_mail(subject=subject,
email_template=template,
recipients_list=[settings.REPS_MENTORS_LIST],
data=data)
mentors = User.objects.filter(groups__name='Mentor')
for mentor in mentors:
ActionItem.create(mentor.userprofile)
开发者ID:Josespaul,项目名称:remo,代码行数:20,代码来源:tasks.py
示例17: create_rotm_poll
def create_rotm_poll():
"""Create a poll for the Rep of the month nominee.
This task will create a range poll after the first days of the month
during which mentors nominated mentees through their user profiles.
The poll will last 14 days.
"""
# Avoid circular dependencies
from remo.voting.models import Poll, RangePoll, RangePollChoice
create_poll_flag = True
poll_name = 'Rep of the month for {0}'.format(number2month(now().month))
start = (datetime.combine(rotm_nomination_end_date(),
datetime.min.time()) + timedelta(days=1))
end = start + timedelta(days=ROTM_VOTING_DAYS)
rotm_poll = Poll.objects.filter(name=poll_name, start=start, end=end)
if not now().date() > rotm_nomination_end_date() or rotm_poll.exists():
create_poll_flag = False
nominees = User.objects.filter(userprofile__registration_complete=True,
userprofile__is_rotm_nominee=True)
if ((nominees and create_poll_flag) or
waffle.switch_is_active('enable_rotm_tasks')):
remobot = User.objects.get(username='remobot')
description = 'Automated vote for the Rep of this month.'
mentor_group = Group.objects.get(name='Mentor')
with transaction.commit_on_success():
poll = Poll.objects.create(name=poll_name,
description=description,
valid_groups=mentor_group,
start=start,
end=end,
created_by=remobot)
range_poll = RangePoll.objects.create(
poll=poll, name='Rep of the month nominees')
for nominee in nominees:
RangePollChoice.objects.create(range_poll=range_poll,
nominee=nominee)
开发者ID:Azeez09,项目名称:remo,代码行数:41,代码来源:tasks.py
示例18: handle
def handle(self, *args, **options):
"""Prepares a list of reps to be notified and the required
template variables.
"""
rep_group = Group.objects.get(name="Rep")
reps = rep_group.user_set.exclude(userprofile__registration_complete=False)
id_reps = reps.values_list("id", flat=True)
date = go_back_n_months(datetime.datetime.today(), 1)
month = number2month(date.month)
subject = self.SUBJECT % month
data = {"year": date.year, "month": month}
if options["dry_run"]:
email_reps = reps.values_list("email", flat=True)
for recipient in email_reps:
msg = "First notification sent to %s" % recipient
print(msg)
else:
send_remo_mail(id_reps, subject, self.EMAIL_TEMPLATE, data)
开发者ID:rishabhsixfeet,项目名称:remo,代码行数:22,代码来源:send_first_report_notification.py
示例19: test_poll_already_exists
def test_poll_already_exists(self, mocked_now_date, mocked_waffle_switch):
mocked_waffle_switch.return_value = False
UserFactory.create(userprofile__is_rotm_nominee=True)
UserFactory.create(userprofile__is_rotm_nominee=True)
UserFactory.create(username='remobot')
# Nomination ends on the 10th of each month
mocked_now_date.return_value = datetime(now().year, now().month, 10)
poll_start = datetime(now().year, now().month, 1)
poll_end = poll_start + timedelta(days=14)
poll_name = ('Rep of the month for {0}'.format(
number2month(now().month)))
mentor_group = Group.objects.get(name='Mentor')
poll = PollFactory.create(start=poll_start,
end=poll_end,
valid_groups=mentor_group,
name=poll_name)
create_rotm_poll()
rotm_polls = Poll.objects.filter(name=poll_name)
ok_(rotm_polls.exists())
eq_(rotm_polls.count(), 1)
eq_(rotm_polls[0].pk, poll.pk)
开发者ID:Azeez09,项目名称:remo,代码行数:24,代码来源:test_tasks.py
注:本文中的remo.base.utils.number2month函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论