def submit_data(self, event=None): major = self.major_entry.get().strip() classification = self.classification_entry.get().strip() name = self.name_entry.get().strip() netid = self.net_id_entry.get().strip() for x in (major, classification, name, netid): if x == "": self.feedback_label.config(style="ErrorLabel.TLabel") self.feedback_label['text'] = 'Make sure there is an entry for every field.' return if self.dues.get() == "two": dues = 2 elif self.dues.get() == "one": dues = 1 else: dues = 0 data = MIS_Database_Functions.check_member(netid) if data is not None: if data['major'] != major: MIS_Database_Functions.set_major(netid, major) Logger.write_to_log(Logger.get_event_log_file(), "Major updated to %s for net id %s\n" % (major, netid)) if data['classification'] != classification: MIS_Database_Functions.set_classification(netid, classification) Logger.write_to_log(Logger.get_event_log_file(), "Classification updated to '%s' for net id '%s'\n" % (classification, netid)) if data['name'] != name: MIS_Database_Functions.set_name(netid, name) Logger.write_to_log(Logger.get_event_log_file(), "Name updated to %s for net id %s\n" % (name, netid)) if data['dues_paid'] != dues and dues > 0: MIS_Database_Functions.update_payment(netid, dues) Logger.write_to_log(Logger.get_event_log_file(), "Payment made for %s, %d semesters paid for\n" % (netid, dues)) if self.payment_made.get() == 0: Logger.write_to_log(Logger.get_event_log_file(), "Payment above NOT collected\n") else: MIS_Database_Functions.create_member(netid, name, major, classification, dues) Logger.write_to_log(Logger.get_event_log_file(), 'New Member: (%s, %s, %s, %s, %d)\n' % (netid, name, major, classification, dues)) if dues > 0: Logger.write_to_log(Logger.get_event_log_file(), "Payment made for %s semesters for net id %s\n" % (str(dues), netid)) if self.payment_made.get() == 0: Logger.write_to_log(Logger.get_event_log_file(), "Payment above NOT collected\n") event_id = MIS_Database_Functions.get_most_recent_event_id() # Weird edge case: when user accidentally presses trial button, may end up recording a trial meeting for a # a user who has already paid for the semester. Code is corrected to make sure the users payment information is # not affected, this just makes sure the logs don't falsely record a trial meeting. if data is None and dues == 0: Logger.write_to_log(Logger.get_event_log_file(), "Trial Meeting for %s\n" % netid) elif hasattr(data, 'dues_paid'): if data['dues_paid'] == 0: Logger.write_to_log(Logger.get_event_log_file(), "Trial Meeting for %s\n" % netid) MIS_Database_Functions.create_ticket(event_id, netid) Logger.write_to_log(Logger.get_event_log_file(), "\n\n") self.clear_all() self.feedback_label.config(style="SuccessLabel.TLabel") self.feedback_label['text'] = name.split(" ")[1] + " was checked in successfully!\n" \ "Welcome them to the meeting!"
def get_data(self, net_id, event=None): if net_id is None or net_id.strip() == "": self.feedback_label.config(style="ErrorLabel.TLabel") self.feedback_label['text'] = "No net ID entered yet." return # Failure state if self.major_entry.get() and self.classification_entry.get(): self.feedback_label.config(style="ErrorLabel.TLabel") self.feedback_label['text'] = "Make sure to clear the entries\n" \ "before trying to gather data." return # Failure State data = MIS_Database_Functions.check_member(net_id) if data is not None: self.name_entry.insert(START, data['name']) self.major_entry.insert(START, data['major']) self.classification_entry.insert(START, data['classification']) if data['dues_paid'] == 2: self.two_semesters.invoke() elif data['dues_paid'] == 1: self.one_semester.invoke() else: self.dues.set("trial") attendance_data = \ MIS_Database_Functions.get_attendance_data(net_id, MIS_Database_Functions.get_most_recent_semester_tag()) if attendance_data is not None: if attendance_data['meetings_attended'] > 0 and attendance_data['dues'] < 1: self.feedback_label.config(style="ErrorLabel.TLabel") self.feedback_label['text'] = "Member %s has already used their trial meeting.\n" \ "They have not yet paid dues.\n" \ "Collect payment as necessary." % net_id else: self.feedback_label.config(style="SuccessLabel.TLabel") self.feedback_label['text'] = "Member %s is paid for %d more semester(s).\n" \ "They have attended %d meetings this semester." % \ (net_id, attendance_data['dues'], attendance_data['meetings_attended']) else: self.feedback_label.config(style="SuccessLabel.TLabel") self.feedback_label['text'] = "This member has not yet used their trial meeting.\n" \ "They are good to go.\n" \ "Collect payment only if they want to pay now." else: try: data = Info_IaState_Scraper.get_raw_html(net_id) data = Info_IaState_Scraper.parse_student_data(data) if data is not None: self.name_entry.insert(START, data['name']) self.major_entry.insert(START, data['major']) self.classification_entry.insert(START, data['classification']) self.feedback_label.config(style="SuccessLabel.TLabel") self.feedback_label['text'] = "No current data on %s.\n" \ "Found data in the directory.\n" \ "New members receive 1 trial meeting." % net_id else: self.feedback_label.config(style="SuccessLabel.TLabel") self.feedback_label['text'] = "No current data on this net id: %s.\n" \ "Nothing found on the directory either. \n" \ "Make sure their net ID is correct.\n" \ "If it is then ask them to type in data " \ "for the other fields.\n" \ "New members receive 1 trial meeting." % net_id except URLError: self.feedback_label.config(style="ErrorLabel.TLabel") self.feedback_label['text'] = 'No current data on net id: %s.\n' \ 'Directory request failed.\n' \ 'Check internet connection then try again.\n' \ 'If all else fails, enter data manually.' % net_id