コード例 #1
0
ファイル: test_util.py プロジェクト: yumsuresht/remo
 def test_get_last_report_future(self):
     past_date = now().date() - timedelta(weeks=5)
     future_date = now().date() + timedelta(weeks=2)
     user = UserFactory.create(groups=['Rep'])
     NGReportFactory.create(user=user, report_date=past_date)
     NGReportFactory.create(user=user, report_date=future_date)
     eq_(get_last_report(user).report_date, past_date)
コード例 #2
0
ファイル: test_util.py プロジェクト: flaki/remo
 def test_get_last_report_future(self):
     past_date = now().date() - timedelta(weeks=5)
     future_date = now().date() + timedelta(weeks=2)
     user = UserFactory.create(groups=["Rep"])
     NGReportFactory.create(user=user, report_date=past_date)
     NGReportFactory.create(user=user, report_date=future_date)
     eq_(get_last_report(user).report_date, past_date)
コード例 #3
0
def get_last_report_date(user):
    """Return user's inactivity level."""
    last_report = get_last_report(user)
    if not last_report:
        return ''

    return last_report.report_date
コード例 #4
0
ファイル: api_v1.py プロジェクト: flaki/remo
 def dehydrate_last_report_date(self, bundle):
     start_period = now().date() - timedelta(weeks=4)
     end_period = now().date() + timedelta(weeks=4)
     reports = bundle.obj.user.ng_reports.filter(
         report_date__range=(start_period, end_period))
     try:
         return reports.latest('report_date').report_date
     except NGReport.DoesNotExist:
         report = get_last_report(bundle.obj.user)
         if report:
             return report.report_date
         return None
コード例 #5
0
ファイル: api_v1.py プロジェクト: sachithamh/remo
 def dehydrate_last_report_date(self, bundle):
     start_period = now().date() - timedelta(weeks=4)
     end_period = now().date() + timedelta(weeks=4)
     reports = bundle.obj.user.ng_reports.filter(
         report_date__range=(start_period, end_period))
     try:
         return reports.latest('report_date').report_date
     except NGReport.DoesNotExist:
         report = get_last_report(bundle.obj.user)
         if report:
             return report.report_date
         return None
コード例 #6
0
ファイル: helpers.py プロジェクト: Mte90/remo
def get_activity_level(user):
    """Return user's inactivity level."""
    last_report = get_last_report(user)
    if not last_report:
        return ""

    today = timezone.now().date()
    inactivity_period = today - last_report.report_date

    if inactivity_period > INACTIVE_LOW:
        if inactivity_period > INACTIVE_HIGH:
            return "inactive-high"
        return "inactive-low"
    return ""
コード例 #7
0
def get_activity_level(user):
    """Return user's inactivity level."""
    last_report = get_last_report(user)
    if not last_report:
        return ''

    today = timezone.now().date()
    inactivity_period = today - last_report.report_date

    if inactivity_period > INACTIVE_LOW:
        if inactivity_period > INACTIVE_HIGH:
            return 'inactive-high'
        return 'inactive-low'
    return ''
コード例 #8
0
ファイル: test_util.py プロジェクト: yumsuresht/remo
 def test_last_report_date_none(self):
     user = UserFactory.create(groups=['Rep'])
     ok_(not get_last_report(user))
     future_date = now().date() + timedelta(weeks=2)
     NGReportFactory.create(user=user, report_date=future_date)
     ok_(not get_last_report(user))
コード例 #9
0
ファイル: test_util.py プロジェクト: yumsuresht/remo
 def test_get_last_report_past(self):
     report_date = now().date() - timedelta(weeks=5)
     user = UserFactory.create(groups=['Rep'])
     NGReportFactory.create(user=user, report_date=report_date)
     eq_(get_last_report(user).report_date, report_date)
コード例 #10
0
ファイル: test_util.py プロジェクト: flaki/remo
 def test_last_report_date_none(self):
     user = UserFactory.create(groups=["Rep"])
     ok_(not get_last_report(user))
     future_date = now().date() + timedelta(weeks=2)
     NGReportFactory.create(user=user, report_date=future_date)
     ok_(not get_last_report(user))
コード例 #11
0
ファイル: test_util.py プロジェクト: flaki/remo
 def test_get_last_report_past(self):
     report_date = now().date() - timedelta(weeks=5)
     user = UserFactory.create(groups=["Rep"])
     NGReportFactory.create(user=user, report_date=report_date)
     eq_(get_last_report(user).report_date, report_date)