예제 #1
0
def calculate_tender_date(date_obj, timedelta_obj, tender, working_days, calendar=WORKING_DAYS):
    tender_date = get_first_revision_date(tender, default=get_now())
    if working_days:
        midnight = tender_date > WORKING_DATE_ALLOW_MIDNIGHT_FROM
        return calc_working_datetime(date_obj, timedelta_obj, midnight, calendar)
    else:
        return calc_datetime(date_obj, timedelta_obj)
def calculate_normalized_business_date(date_obj,
                                       timedelta_obj,
                                       accelerator=None):
    if accelerator:
        return calc_datetime(date_obj, timedelta_obj, accelerator)
    normalized_date = calc_normalized_datetime(
        date_obj, ceil=timedelta_obj > timedelta())
    return calc_working_datetime(normalized_date,
                                 timedelta_obj,
                                 midnight=True,
                                 calendar=WORKING_DAYS)
예제 #3
0
def calculate_framework_date(date_obj,
                             timedelta_obj,
                             framework=None,
                             working_days=False,
                             calendar=WORKING_DAYS,
                             ceil=False):
    date_obj = calc_normalized_datetime(date_obj, ceil=ceil)
    if working_days:
        return calc_working_datetime(date_obj,
                                     timedelta_obj,
                                     calendar=calendar)
    else:
        return calc_datetime(date_obj, timedelta_obj)
예제 #4
0
파일: plan.py 프로젝트: lttga/op2
 def _check_field_change_events(self, src_data, plan):
     src_identifier = src_data["procuringEntity"]["identifier"]
     identifier = plan["procuringEntity"]["identifier"]
     if src_identifier["scheme"] != identifier["scheme"] or src_identifier[
             "id"] != identifier["id"]:
         if any(m["status"] in Milestone.ACTIVE_STATUSES
                for m in src_data.get("milestones", "")):
             standstill_end = calc_working_datetime(
                 get_now(), PROCURING_ENTITY_STANDSTILL)
             if standstill_end > plan["tender"]["tenderPeriod"]["startDate"]:
                 raise_operation_error(
                     self.request,
                     "Can't update procuringEntity later than {} "
                     "business days before tenderPeriod.StartDate".format(
                         PROCURING_ENTITY_STANDSTILL.days))
             # invalidate active milestones and update milestone.dateModified
             plan.dateModified = get_now()
             plan.modified = False
             for m in plan.milestones:
                 if m.status in Milestone.ACTIVE_STATUSES:
                     m.status = Milestone.STATUS_INVALID
                     m.dateModified = plan.dateModified
    def test_patch_to_active(self):
        self.app.authorization = ('Basic', (self.sas_name, self.sas_pass))

        context = self.acceleration if SANDBOX_MODE else {}
        accelerator = get_monitoring_accelerator(context)

        now_date = datetime.now(TZ)
        if accelerator:
            end_date = calc_datetime(
                now_date,
                MONITORING_TIME,
                accelerator=accelerator
            )
        else:
            end_date = calc_working_datetime(
                now_date,
                MONITORING_TIME,
                midnight=True,
                calendar=WORKING_DAYS
            )
        response = self.app.patch_json(
            '/monitorings/{}'.format(self.monitoring_id),
            {"data": {
                "status": "active",
                "decision": {
                    "description": "text",
                    "date": (now_date - timedelta(days=2)).isoformat()
                }
            }}
        )

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content_type, 'application/json')
        self.assertEqual(response.json['data']["status"], "active")
        self.assertEqual(response.json['data']["monitoringPeriod"]["startDate"], now_date.isoformat())
        self.assertEqual(response.json['data']["dateModified"], now_date.isoformat())
        self.assertEqual(response.json['data']["monitoringPeriod"]["endDate"], end_date.isoformat())
        self.assertEqual(response.json['data']["endDate"], end_date.isoformat())