def get(self, serviceKeyUrlSafe): user = Authorization.isAuthenticated() if user: ServiceService.delete(serviceKeyUrlSafe) self.redirect('/services') else: self.redirect('/')
def post(self): user = Authorization.isAuthenticated() if user: try: ServiceService.add(self.request) except: logging.error("ServiceAdd.py => post(self) => an exception was thrown trying to create a new Service") finally: self.redirect('/services') else: self.redirect('/')
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 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 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 get(self): user = Authorization.isAuthenticated() if user: services = ServiceService.getAll() template_values = { 'services':services } template = JINJA_ENVIRONMENT.get_template('partials/services.html') self.response.write(template.render(template_values)) else: self.redirect('/')
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('/')
def get(self, lineItemKeyUrlSafe, clientKeyUrlSafe): user = Authorization.isAuthenticated() if user: client = ClientService.get(clientKeyUrlSafe) lineItem = LineItemService.get(lineItemKeyUrlSafe) services = ServiceService.getAll() template_values = { "client": client, "lineItem": lineItem, "services": services, "postURL": "/lineItemUpdate/" + lineItemKeyUrlSafe + "/client/" + clientKeyUrlSafe, } template = JINJA_ENVIRONMENT.get_template("partials/lineItemUpdate.html") self.response.write(template.render(template_values)) else: self.redirect("/")
def get(self, clientKeyUrlSafe): user = Authorization.isAuthenticated() if user: monthStart = DateService.getFirstDateOfMonth().strftime('%m/%d/%Y') monthEnd = DateService.getLastDateOfMonth().strftime('%m/%d/%Y') try: radLineItemType = LineItemsClient.radLineItemType except: radLineItemType = 'irregular' try: dateFrom = LineItemsClient.dateFrom dateTo = LineItemsClient.dateTo except: dateFrom = monthStart dateTo = monthEnd try: viewDateFrom = LineItemsClient.viewDateFrom viewDateTo = LineItemsClient.viewDateTo except: viewDateFrom = monthStart viewDateTo = monthEnd try: serviceKeyUrlSafe = LineItemsClient.serviceKeyUrlSafe except: serviceKeyUrlSafe = '' services = ServiceService.getAll() client = ClientService.get(clientKeyUrlSafe) # lineItems = LineItemService.getAll(clientKeyUrlSafe) lineItems = LineItemService.getAllInRange(clientKeyUrlSafe, viewDateFrom, viewDateTo) template_values = { 'services':services, 'client' : client, 'postUrl' : '/lineItem/client/' + clientKeyUrlSafe, 'lineItems' : lineItems, 'getUrl' : '/lineItem/client/' + clientKeyUrlSafe, 'viewDateFrom' : viewDateFrom, 'viewDateTo' : viewDateTo, 'dateFrom' : dateFrom, 'dateTo' : dateTo, 'serviceKeyUrlSafe' : serviceKeyUrlSafe, 'radLineItemType' : radLineItemType } template = JINJA_ENVIRONMENT.get_template('partials/lineItemClient.html') self.response.write(template.render(template_values)) else: self.redirect('/')