def addAllInRange(clientKeyUrlSafe, request): clientKey = ClientService.getClientKey(clientKeyUrlSafe) serviceKeyUrlSafe = request.get("serviceKeyUrlSafe") service = ServiceService.get(serviceKeyUrlSafe) dateFromString = request.get("dateFrom") dateToString = request.get("dateTo") repeatMonday = request.get("repeatMonday") repeatTuesday = request.get("repeatTuesday") repeatWednesday = request.get("repeatWednesday") repeatThursday = request.get("repeatThursday") repeatFriday = request.get("repeatFriday") repeatSaturday = request.get("repeatSaturday") repeatSunday = request.get("repeatSunday") startDate = datetime.strptime(dateFromString, "%m/%d/%Y").date() endDate = datetime.strptime(dateToString, "%m/%d/%Y").date() dateRange = endDate - startDate for i in range(dateRange.days + 1): currentDay = startDate + timedelta(days=i) if repeatSunday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.SUNDAY: LineItemService.add(clientKey, service, currentDay) if repeatMonday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.MONDAY: LineItemService.add(clientKey, service, currentDay) if repeatTuesday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.TUESDAY: LineItemService.add(clientKey, service, currentDay) if repeatWednesday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.WEDNESDAY: LineItemService.add(clientKey, service, currentDay) if repeatThursday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.THURSDAY: LineItemService.add(clientKey, service, currentDay) if repeatFriday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.FRIDAY: LineItemService.add(clientKey, service, currentDay) if repeatSaturday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.SATURDAY: LineItemService.add(clientKey, service, currentDay)
def update(lineItemKeyUrlSafe, request): serviceDate = request.get("serviceDate") serviceKeyUrlSafe = request.get("serviceKeyUrlSafe") lineItemKey = LineItemService.getLineItemKey(lineItemKeyUrlSafe) service = ServiceService.get(serviceKeyUrlSafe) lineItem = lineItemKey.get() serviceDate = datetime.strptime(serviceDate, "%m/%d/%Y").date() lineItem.service = service lineItem.dateOfService = serviceDate lineItem.put()
def addAllInList(clientKeyUrlSafe, request): dateList = request.get("multiDatesPickerSelectedDates") clientKey = ClientService.getClientKey(clientKeyUrlSafe) dateList = dateList.split(",") serviceKeyUrlSafe = request.get("serviceKeyUrlSafe") service = ServiceService.get(serviceKeyUrlSafe) for dateString in dateList: dateString = dateString.strip() currentDate = datetime.strptime(dateString, "%m/%d/%Y").date() LineItemService.add(clientKey, service, currentDate)
def get(self, serviceKeyUrlSafe): user = Authorization.isAuthenticated() if user: service = ServiceService.get(serviceKeyUrlSafe) template_values={ 'service':service, 'buttonName' : 'Update', 'postURL' : '/serviceUpdate/' + serviceKeyUrlSafe } template = JINJA_ENVIRONMENT.get_template('partials/serviceEditable.html') self.response.write(template.render(template_values)) else: self.redirect('/')