def gather_data(self): #TODO: Alias MIS_Database_Functions, these lines are way to long prev_event_aggregates = MIS_Database_Functions.get_event_aggregates( MIS_Database_Functions.get_most_recent_event_id()) # Event that just happened curr_event_aggregates = MIS_Database_Functions.get_event_aggregates( MIS_Database_Functions.get_most_recent_event_id()-1) # Event before that prev_event_classifications = MIS_Database_Functions.get_event_classification_aggregates( MIS_Database_Functions.get_most_recent_event_id()) curr_event_classifications = MIS_Database_Functions.get_event_classification_aggregates( MIS_Database_Functions.get_most_recent_event_id()-1) self.target_major = MIS_Database_Functions.select_config_info('target_major') for aggregate in prev_event_aggregates: self.prev_event_data[aggregate] = prev_event_aggregates[aggregate] for aggregate in curr_event_aggregates: self.curr_event_data[aggregate] = curr_event_aggregates[aggregate] for classification in prev_event_classifications: self.prev_event_data['classification'][classification] = prev_event_classifications[classification] for classification in curr_event_classifications: self.curr_event_data['classification'][classification] = curr_event_classifications[classification] return True
def populate_event_label(self): semester_tag = MIS_Database_Functions.get_most_recent_semester_tag() if semester_tag is None: # Failure State self.current_label.config(style="ErrorLabel.TLabel") self.current_label['text'] = 'No semester created yet!\n' \ 'Create one first, then\n' \ 'restart this system. :)' return event_id = MIS_Database_Functions.get_most_recent_event_id() if event_id is not None: event_data = MIS_Database_Functions.get_event_data(event_id) self.current_label['text'] = 'Newest Event:\n%s' % (event_data['company']) else: self.feedback_label.config(style="ErrorLabel.TLabel") self.current_label['text'] = 'No event yet.\nCreate one here.'
def set_focus(self): # Populate information in the currency labels event_id = MIS_Database_Functions.get_most_recent_event_id() if event_id is not None: data = MIS_Database_Functions.get_event_data(event_id) self.currency_label['text'] = "Current Check In:\n%s" % data['company'] else: self.currency_label['text'] = "Not ready to check in yet.\nPlease create an event." self.currency_label.config(style='ErrorLabel.TLabel') # Set the tab indexes tab_order_tuple = (self.net_id_entry, self.get_data_button, self.submit_data_button, self.clear_all_button, self.verify_button) for widget in tab_order_tuple: widget.lift() tab_order_tuple[0].focus()
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!"