Ejemplo n.º 1
0
    def load(self, year, month):
        """load calendar with data from database"""
        #temp = models.EventCalendar.objects.filter(owner=self.owner, 
        #        year=year, month=month)

        temp = models.EventCalendar.objects.all()
        if temp:    # either 1 record or no record , check models.py
	    if len(temp) == 1:
              self.db_cal = temp[0]
	    else:
	      for cale in temp:
	        if cale.owner == self.owner:
	          self.db_cal = cale
            self.db_events = models.RunningNight.objects.filter(cal=self.db_cal,
                    date__year=year, date__month=month)

            self.curr = eventCalBase.monthCalendar(self.db_cal.id, 
                    self.owner, year, month)
            for db_e in self.db_events:
                e = eventCalBase.event(id=db_e.id, name=db_e.name, date=db_e.date,
                        end=db_e.end, cars=db_e.cars, descr=db_e.descr, evtype=db_e.evtype)
                self.curr.addEvent(e, db_e.date.day)
        else:
            self.curr = eventCalBase.monthCalendar(None, self.owner, 
                    year, month)
Ejemplo n.º 2
0
    def load(self, year, month):
        """load calendar with data from database"""
        temp = models.EventCalendar.objects.filter(owner=self.owner, 
                year=year, month=month)
        if temp:    # either 1 record or no record , check models.py
            self.db_cal = temp[0]
            self.db_events = models.Event.objects.filter(cal=self.db_cal,
                    when__year=year, when__month=month)

            self.curr = eventCalBase.monthCalendar(self.db_cal.id, 
                    self.owner, year, month)
            for db_e in self.db_events:
                e = eventCalBase.event(db_e.id, db_e.name, db_e.when,
                        db_e.desc)
                self.curr.addEvent(e, db_e.when.day)
        else:
            self.curr = eventCalBase.monthCalendar(None, self.owner, 
                    year, month)
Ejemplo n.º 3
0
    def load(self, year, month):
        """load calendar with data from database"""

        temp = filter_samples(0,month,year,0)
        if temp:    # either 1 record or no record , check models.py
            self.db_cal = temp[0]

            if self.area == 0:
                self.db_events = filter_samples(0,month,year,self.area)
            else:
                self.db_events = filter_samples(0,month,year,self.area)
            self.curr = eventCalBase.monthCalendar(self, year, month)
#put events to map a month
            for db_e in self.db_events:
                e = eventCalBase.event(db_e.id, db_e.taken_by,db_e.date_taken, db_e.sampling_point)
                self.curr.addEvent(e, db_e.date_taken.day)
        else:
            self.curr = eventCalBase.monthCalendar(None,
                    year, month)
Ejemplo n.º 4
0
    def load(self, year, month):
        """load calendar with data from database"""
        temp = models.EventCalendar.objects.filter(owner=self.owner,
                                                   year=year,
                                                   month=month)
        if temp:  # either 1 record or no record , check models.py
            self.db_cal = temp[0]
            self.db_events = models.Event.objects.filter(cal=self.db_cal,
                                                         when__year=year,
                                                         when__month=month)

            self.curr = eventCalBase.monthCalendar(self.db_cal.id, self.owner,
                                                   year, month)
            for db_e in self.db_events:
                e = eventCalBase.event(db_e.id, db_e.name, db_e.when,
                                       db_e.desc)
                self.curr.addEvent(e, db_e.when.day)
        else:
            self.curr = eventCalBase.monthCalendar(None, self.owner, year,
                                                   month)
Ejemplo n.º 5
0
    def load(self, year, month):
        """load calendar with data from database"""
        
        temp = Sample.objects.filter(date_taken__year=year, date_taken__month=month)
        if temp:    # either 1 record or no record , check models.py
            self.db_cal = temp[0]
            
            if self.area == 0:
                self.db_events = Sample.objects.filter(date_taken__year=year, date_taken__month=month)
            else:
                a = Sample.objects.filter(date_taken__year=year, date_taken__month=month)
                self.db_events = a.filter(sampling_point__wqmarea = self.area)
            self.curr = eventCalBase.monthCalendar(self, year, month)
#put events to map a month
            for db_e in self.db_events:              
                e = eventCalBase.event(db_e.id, db_e.taken_by,db_e.date_taken, db_e.sampling_point)
                self.curr.addEvent(e, db_e.date_taken.day)
        else:
            self.curr = eventCalBase.monthCalendar(None,
                    year, month)
Ejemplo n.º 6
0
 def setUp(self):
     self.emsg = 'Expect %s, got %s'
     self.now = datetime.datetime.now()
     self.cal = eventCalBase.monthCalendar(1, 'someone', self.now.year, 
             self.now.month)
Ejemplo n.º 7
0
 def setUp(self):
     self.emsg = 'Expect %s, got %s'
     self.now = datetime.datetime.now()
     self.cal = eventCalBase.monthCalendar(1, 'someone', self.now.year,
                                           self.now.month)