Exemple #1
0
def createSession(p):
    "Create a new session for the tests"
    sem = Semester.objects.get(semester = '12A')
    data  = {
        'name' : 'nextSemesterSession'
      , 'pcode' : p.pcode
      , 'grade' : 'A'  
      , 'semester' : sem
      , 'requested_time' : 3.5  
      , 'allocated_time' : 3.5  
      , 'allocated_repeats' : 1  
      , 'session_type' : 'Open - Low Freq'
      , 'observing_type' : 'continuum' 
      , 'weather_type' : 'Poor'
      , 'repeats' : 2 
      , 'min_lst' : '10:00:00.0' 
      , 'max_lst' : '20:00:00.0' 
      , 'elevation_min' : '00:00:00.0' 
      , 'next_sem_complete' : False
      , 'next_sem_time' : 1.0
      , 'receivers' : 'L'
    }

    adapter = SessionHttpAdapter()
    adapter.initFromPost(data)
    # just so that is HAS a DSS session.
    #adapter.session.dss_session = self.maintProj.sesshun_set.all()[0]
    adapter.session.save()
    return adapter.session
Exemple #2
0
 def delete(self, request, *args, **kws):
     id,   = args
     session = Session.objects.get(id = id)
     session.delete()
     adapter = SessionHttpAdapter(session)
     adapter.notify(session.proposal)
     return HttpResponse(json.dumps({"success" : "ok"})
                       , content_type = 'application/json')
Exemple #3
0
 def create(self, request, *args, **kws):
     adapter  = SessionHttpAdapter()
     adapter.initFromPost(json.loads(request.raw_post_data))
     sessions = [adapter.jsonDict(detailed = True)]
     return HttpResponse(json.dumps({ 'success' : 'ok'
                                    , self.root : sessions
                         })
                       , content_type = 'application/json')
     return response
Exemple #4
0
    def checkDB(self):
        proposals = [Proposal.objects.get(id = id) for id in self.ids]
        print "Modified Proposals: ", ', '.join([p.pcode for p in proposals])
        for p in proposals:
            print "PCode\t\tRq.\tAllot."
            print "%s\t%s\t%s" % (p.pcode, p.requestedTime(), p.allocatedTime())

            print "\tName\t\tGrade\tRq.\tAllot."
            for s in p.session_set.all().order_by('name'):
                sa = SessionHttpAdapter(s)
                data = sa.jsonDict()
                print "\t%s\t%s\t%s\t%s" % (data['name'], data['grade'], data['requested_total'], data['allocated_time'])
 def test_jsonDictAllHP(self):
     sa = SessionHttpAdapter(session = Session.objects.all()[0])
     # here's what the json for this session looks like when
     # we use the ORM
     ormJson = sa.jsonDict()
     # here's what the json for this session looks like when
     # we use the high performance query of the DB
     sqlJsons = sa.jsonDictAllHP()
     self.assertEqual(1, len(sqlJsons))
     sqlJson = sqlJsons[0]
     #keys = ormJson.keys()
     #for k in sorted(keys):
     #    print k, " : ", ormJson[k]
     #print "********************"
     #keys = sqlJson.keys()
     #for k in sorted(keys):
     #    print k, " : ", sqlJson[k]
     self.assertEqual(ormJson, sqlJson)
Exemple #6
0
 def read(self, request, *args, **kws):
     if len(args) == 1:
         id,   = args
         adapter  = SessionHttpAdapter(Session.objects.get(id = id))
         return HttpResponse(json.dumps(adapter.jsonDict(detailed = True))
                           , content_type = 'application/json')
     else:
         # Keep this here for when we start doing pagenation
         """
         start = request.GET.get('start', 0)
         limit = request.GET.get('limit', 25)
         end   = int(start) + int(limit)
         """
         #sessions = Session.objects.all()
         sessions = SessionHttpAdapter.jsonDictAllHP()
         return HttpResponse(json.dumps({"success" : "ok"
                                       #, "sessions" : [SessionHttpAdapter(s).jsonDict() for s in sessions]
                                       , "sessions" : sessions
                                       , "total" : len(sessions)
                                        })
                           , content_type = 'application/json')
    def createCarryOverSession(self):
        """
        Creates a PHT Session that will contribute to the carryover:
           * intersects with Galactic Center
           * L band - Low Freq group
           * Grade A
           * Next Semester time to complete
        """

        sem = Semester.objects.get(semester = '12A')
        p = Proposal.objects.all()[0]

        data  = {
            'name' : 'nextSemesterSession'
          , 'pcode' : p.pcode
          , 'grade' : 'A'  
          , 'semester' : sem
          , 'requested_time' : 3.5  
          , 'allocated_time' : 3.5  
          , 'session_type' : 'Open - Low Freq'
          , 'observing_type' : 'continuum' 
          , 'weather_type' : 'Poor'
          , 'repeats' : 2 
          , 'min_lst' : '10:00:00.0' 
          , 'max_lst' : '20:00:00.0' 
          , 'elevation_min' : '00:00:00.0' 
          , 'next_sem_complete' : False
          , 'next_sem_time' : 1.0
          , 'receivers' : 'L'
        }

        adapter = SessionHttpAdapter()
        adapter.initFromPost(data)
        # just so that is HAS a DSS session.
        adapter.session.dss_session = self.maintProj.sesshun_set.all()[0]
        adapter.session.save()
        return adapter.session
Exemple #8
0
 def update(self, request, *args, **kws):
     id,   = args
     adapter  = SessionHttpAdapter(Session.objects.get(id = id))
     adapter.updateFromPost(json.loads(request.raw_post_data))
     return HttpResponse(json.dumps({"success" : "ok"})
                       , content_type = 'application/json')