Beispiel #1
0
def create_session(sesshun, project, fdata):
    "Utility method for creating a Sesshun to test."

    fsestype = fdata.get("type", "open")
    fobstype = fdata.get("science", "testing")
    proj_code = fdata.get("pcode", "Test-Project")

    st = Session_Type.objects.get(type = fsestype)
    ot = Observing_Type.objects.get(type = fobstype)

    sesshun.project          = project
    sesshun.session_type     = st
    sesshun.observing_type   = ot
    sesshun.original_id      = 0
    sesshun.name             = fdata.get("name", None)
    sesshun.frequency        = fdata.get("freq", None)
    sesshun.max_duration     = TimeAgent.rndHr2Qtr(float(fdata.get("req_max", 12.0)))
    sesshun.min_duration     = TimeAgent.rndHr2Qtr(float(fdata.get("req_min",  3.0)))
    sesshun.time_between     = fdata.get("between", None)

    allot = Allotment(psc_time          = fdata.get("PSC_time", 0.0)
                    , total_time        = fdata.get("total_time", 0.0)
                    , max_semester_time = fdata.get("sem_time", 0.0)
                    , grade             = fdata.get("grade", 4.0)
                      )
    allot.save()
    sesshun.allotment        = allot

    status = Status(
               enabled    = get_field(fdata, "enabled", True, bool)
             , authorized = get_field(fdata, "authorized", True, bool)
             , complete   = get_field(fdata, "complete", True, bool) 
             , backup     = get_field(fdata, "backup", True, bool) 
                    )
    status.save()
    sesshun.status = status
    sesshun.save()

    create_lst_exclusion(sesshun, fdata)
    
    proposition = fdata.get("receiver")
    save_receivers(sesshun, proposition)
    
    systemName = fdata.get("coord_mode", "J2000")
    system = System.objects.get(name = systemName)

    v_axis = fdata.get("source_v", 0.0)
    h_axis = fdata.get("source_h", 0.0)
    
    target = Target(session    = sesshun
                  , system     = system
                  , source     = fdata.get("source", None)
                  , vertical   = v_axis
                  , horizontal = h_axis
                    )
    target.save()
    sesshun.save()

    return sesshun