def tot_cost(user): sum1 = 0 #print(user) try: s1 = Food.get(Food.owner_id == user).cost if s1 is not None: sum1 = s1 + sum1 print("the total cost of food is") print(s1) except: pass try: s2 = Activity.get(Activity.owner_id == user).cost if s2 is not None: sum1 = s2 + sum1 print("Cost of your activity is") print(s2) except: pass try: s3 = Room.get(Room.owner_id == user).cost if s3 is not None: sum1 = s3 + sum1 print("Cost of your Room is") print(s3) except: pass print(sum1)
def get(self): room_key = self.request.get('room_key') room = Room.get(room_key) data_list = [] #data_list = room.getRoomProfile() data_list.append({'roomNumber':room.roomNumber,'area':room.area,'rentSingle':room.rentSingle,'rentDouble':room.rentDouble}) output_json = json.dumps(data_list) self.response.out.write(output_json)
def get(self, room_id): fields = self.get_only_fields() try: room = model_to_dict( Room.get(id=room_id), only=fields) self.set_response(dict(room=room)) except Room.DoesNotExist: self.set_response( {'message': 'A room with id #{} not found'.format(room_id)}, status=404)
def rooms_edit(request): id = int(request.GET.get('id')) room = Room.get(db.Key.from_path('Room', id)) if request.method != 'POST': form = RoomForm(instance=room) return respond(request, 'room_edit.html', {'form': form, 'id': id }) form = RoomForm(request.POST,instance=room) if form.is_valid(): entity = form.save() entity.put() return HttpResponseRedirect(reverse(rooms)) else: return respond(request, 'room_edit.html', {'form': form })
def get(self, room_id): try: room = Room.get(id=room_id) customers = Customer.select().join(Booking).join(Room).where(Room.id == room_id) customers = map(lambda customer: model_to_dict( customer, append_attrs={'url': self.reverse_url('customer', customer.id)}), customers) room = model_to_dict( room, append_attrs=dict(customers=customers) ) self.set_response(dict(room=room)) except Room.DoesNotExist: self.set_response( {'message': 'A room with id #{} not found'.format(room_id)}, status=404)
def get(self, room_id): try: room = Room.get(id=room_id) booking = Booking.select().where(Booking.room_id == room_id) booking = map(lambda item: model_to_dict( item, append_attrs={'url': self.reverse_url('booking_order', item.id)}, exclude=[Booking.room]), booking) room = model_to_dict( room, append_attrs=dict(booking=booking) ) self.set_response(dict(room=room)) except Room.DoesNotExist: self.set_response( {'message': 'A room with id #{} not found'.format(room_id)}, status=404)
def rooms_delete(request): id = int(request.GET.get('id')) room = Room.get(db.Key.from_path('Room', id)) room.active = False room.put() return HttpResponseRedirect(reverse(rooms))