A mirror of dcurooms found at https://github.com/theycallmemac/dcurooms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 regels
1.8 KiB

  1. import datetime
  2. from optparse import OptionParser
  3. from lab_booking import LabBooking
  4. from room_booking import RoomBooking
  5. from lookup import LookUp
  6. from now import Now
  7. import utils
  8. __author__ = "theycallmemac"
  9. __version__ = '2.0.0'
  10. __copyright__ = 'Copyright (c) 2018 theycallmemac'
  11. __license__ = 'GPL-3.0'
  12. def get_lab_credentials():
  13. return utils.get_version_email()
  14. def get_room_credentials():
  15. return utils.get_version_form()
  16. def booking_lab(info):
  17. email, password, your_name, society = get_lab_credentials()
  18. lab = LabBooking(email, password, your_name, society, info[1])
  19. emails, message = lab.draft()
  20. print(message)
  21. conf = utils.confirm()
  22. if conf == "y":
  23. result = lab.send(emails[0], emails[1], message)
  24. print(result)
  25. else:
  26. "Booking cancelled."
  27. def booking_room(info):
  28. email, number, name, society = get_room_credentials()
  29. room = RoomBooking(email, number, name, society, info[1])
  30. form = room.fill()
  31. conf = utils.confirm()
  32. if conf == "y":
  33. result = room.submit(form)
  34. print(result)
  35. else:
  36. "Booking cancelled."
  37. def lookup_building(rooms, info, options):
  38. lst = utils.get_lst(rooms[0], rooms[1], options)
  39. week, day, hour = info[1]
  40. look = LookUp(week, day, hour)
  41. utils.check_args(week, day)
  42. look.check_time(info[0])
  43. look.building_option(lst)
  44. def lookup_room(info):
  45. room, week, day, hour = info[1]
  46. look = LookUp(week, day, hour)
  47. utils.check_args(week, day)
  48. look.check_time(info[0])
  49. look.room_option(room)
  50. def now(rooms, info, options):
  51. week, day, hour, minute = utils.get_current_time(datetime.datetime.now())
  52. now = Now(week, day, hour, minute)
  53. now.round_it()
  54. utils.check_args(week, day)
  55. now.check_time(info[0])
  56. lst = utils.get_lst(rooms[0], rooms[1], options)
  57. now.building_option(lst, options)