Example #1
0
    def open_chkupdata(self, obsid, ver):
        """
        return obsid.version or a list of possible obsid.version selections
        input:  obsid   --- obsid
                ver     --- version. if it is a blank, it will return a list of possible choices
        output: vobs    --- if version is given, <obsid>.<version>
                vlist   --- if version is not given, a list of possible selction. 
        """
        #
        #--- version value is given, convert it to correct form
        #
        if ver != '':
            ver = int(float(ver))

            if ver < 10:
                ver = '00' + str(ver)
            elif ver < 100:
                ver = '0' + str(ver)
            else:
                ver = str(ver)
            vobs = str(obsid) + '.' + str(ver)
            return vobs
#
#--- version value is not given, extract possible selctions and return a list
#
        else:

            olist = oda.select_data_for_obsid(str(obsid))
            vlist = []
            for ent in olist:
                vlist.append(ent[0])

            return vlist
Example #2
0
def check_higher_obsidrev(obsidrev):
    """
    check whether higher revsion is already verified
    input:  obsidrev    --- obsid + revision #
    output: chk         --- 1 if there is higher resiion verified. 0 otherwise
    """
    atemp = re.split('\.', obsidrev)
    obsid = atemp[0]
    iobsidrev = float(obsidrev)
    #
    #--- extract the entries with the same obsid from sql Updates
    #
    alist = oda.select_data_for_obsid(obsid)
    #
    #--- higher obsidrev is already verified
    #
    chk = 0
    if len(alist) > 1:
        for ent in alist:
            comp = float(ent[0])
            if comp <= iobsidrev:
                continue
            else:
                if ent[4] != 'NA':
                    chk = 1
                    break

    return chk
Example #3
0
    def extract_data_for_display(self):
        """
        extract data which arenot verified and those which were verified in the past "interval" days
        input: interval --- time span in day which you want to display toward the past: default=1
               obsid    --- obsid, defalut <blank> (ignored)
               prop_num --- proposal number: defalut: <blank> (ignored)
        output: alist   a list of lists of extracted data
    
                        [obsidrev, general, acis, si mode, verified, seq number, poc, date, 
                         name of gen_status, name of acis_status, name of si mode stateus, 
                         name of verified status, new comments?, large coord shift?, multi rev?, 
                         higher rev?, obsidrev (for prev), in approved list?]
        """
        #
        #--- selected by obsid
        #
        if self.disp_obsid != '':
            alist = oda.select_data_for_obsid(self.disp_obsid)
#
#--- selected by seqno
#
        elif self.seqno != '':
            alist = oda.select_data_for_seqno(self.seqno)
#
#--- selected by prop_num
#
        elif self.prop_num != '':

            alist = self.select_data_for_prop_num(self.prop_num)
#
#--- normal cases or selected by date interval
#
        else:
            odate = ocf.find_date_of_interval_date_before(self.interval)
            alist = oda.get_data_newer_than_date(odate)
            #
            #--- find data which are not verified and add it if the data include only the day before
            #
            if self.interval == 1:
                alist2 = oda.select_non_signed_off('verified')
                alist = alist + alist2
#
#--- get unique entries
#
            alist = ocf.find_unique_entries(alist)
            alist = self.add_extra_information(alist)

        return alist
Example #4
0
File: views.py Project: tisobe/Ocat
def find_from_updates_list(obsid, approved, submitter):
    """
    find basic information of obsid from updates_list
    input:  obsid       --- obsid
            approve     --- approved status
            submitter   --- submitter's ID
    output: a list of information:
                    [obsid, seqno, propno, pi, target, title, poc, note, pname, sind]
                    where pname is form paramter name to be passed
                          sind  is an inidcator of whether the submitter can approved
    """

    sind = 'y'
    dat_list = oda.select_data_for_obsid(obsid)

    if len(dat_list) > 0:

        obsidrev = dat_list[0][0]
        dat_dict = oda.read_updates_entries_to_dictionary(obsidrev)
#
#--- check whether it really has information needed
#
        if dat_dict['seq_nbr'][0] != 'na':
            seqno  = dat_dict['seq_nbr'][0]
            propno = dat_dict['prop_num'][0]
            target = dat_dict['targname'][0]
            title  = dat_dict['title'][0]
            poc    = dat_dict['poc'][0]
            try:
                simode = dat_dict['si_mode'][0]
            except:
                simode = ''
            note   = ''
#
#--- sometime poc changes depending of defferent revisioin. so check all of them
#
            poc_list = []
            for ent in dat_list:
                obsidrev = ent[0]
                dat_dict = oda.read_updates_entries_to_dictionary(obsidrev)
                poc      = dat_dict['poc'][0]
                poc_list.append(poc)

            if approved == 0:
                note = 'this observation is already on approved list.'
                sind = 'n'
            else:
                if submitter not in poc_list:
                    note = 'you are not POC (' + poc + ') of this observation.'
                    sind = 'n'
#
#--- if si mode is not defined, you cannot approve
#
            if simode in (None, 'NONE', 'None', 'No', 'NO', 'N', 'NA', 'NULL', '\s+', ''):
                note =  note + 'no si mode is given.'

                sind = 'n'
#
#--- check whether the observation is already on OR list
#
            if ocf.is_in_orlist(obsid):
                note =  note + 'in Active OR List.'
                sind = 'n'
#
#--- pname is parameter name used on web pages
#
            pname = 'obsid_' + str(obsid)
            out = [obsid, seqno, propno, target, title, note, pname, sind]
        else:
            out = None
    else:
        out = None

    return out
Example #5
0
def check_multi_entries(obsidrev, verified, notes_list):
    """
    generate indicators for multiple entries
    input:  obsidrev    --- obsid + revision #
            verified    --- whether this obsidrev is verified
            notes_list  --- a list of indicators
    output: notes_list  --- an updated list of indicators
                            add, whether there is multiple obsidrev entries open
                                 whether a higher than this obsidrev is already signed off
                                 if so, which obsidrev (if not, give '0')
    """

    atemp = re.split('\.', obsidrev)
    obsid = atemp[0]
    iobsidrev = float(obsidrev)
    #
    #--- extract the entries with the same obsid from sql Updates
    #
    alist = oda.select_data_for_obsid(obsid)
    #
    #--- check multiple entries are opened
    #
    if len(alist) > 1:
        chk1 = 0
        chk2 = 0
        for ent in alist:
            comp = float(ent[0])
            #
            #--- check multiple entry case
            #
            if ent[4] == 'NA':
                if verified == 'NA':
                    if comp != iobsidrev:
                        chk1 = 1
#
#--- check whether the higher entries are signed off
#
            else:
                if verified == 'NA':
                    if comp > iobsidrev:
                        hobsidrev = str(comp)
                        chk2 = 1
                        break

        if chk1 > 0:
            notes_list.append('y')
        else:
            notes_list.append('n')

        if chk2 > 0:
            notes_list.append('y')
            notes_list.append(
                hobsidrev)  #--- hobsidrev is the higher signed off obsidrev
        else:
            notes_list.append('n')
            notes_list.append('0')
    else:
        notes_list.append('n')
        notes_list.append('n')
        notes_list.append('0')

    return notes_list