Ejemplo n.º 1
0
    def check_web(self, event=None):
        netid = self.net_id_entry.get()
        self.feedback_label.config(style="ErrorLabel.TLabel")
        self.feedback_label['text'] = 'No net id to verify.'
        if netid.strip() == "":
            return

        try:
            raw = Info_IaState_Scraper.get_raw_html(netid)
            parsed = Info_IaState_Scraper.parse_student_data(raw)
            if parsed is not None:
                self.feedback_label.config(style='SuccessLabel.TLabel')
                self.feedback_label['text'] = 'Verification Results:\n'
                #TODO: Can probably refactor this to make it shorter, use for in loop of the object attributes
                if parsed['name'] != self.name_entry.get():
                    self.name_entry.delete(0, len(self.name_entry.get()))
                    self.name_entry.insert(0, parsed['name'])
                    self.feedback_label['text'] += 'Name updated to: %s\n' % parsed['name']
                if parsed['classification'] != self.classification_entry.get():
                    self.classification_entry.delete(0, len(self.classification_entry.get()))
                    self.classification_entry.insert(0, parsed['classification'])
                    self.feedback_label['text'] += 'Classification updated to: %s\n' % parsed['classification']
                if parsed['major'] != self.major_entry.get():
                    self.major_entry.delete(0, len(self.major_entry.get()))
                    self.major_entry.insert(0, parsed['major'])
                    self.feedback_label['text'] += 'Major updated to: %s' % parsed['major']
            else:
                self.feedback_label.config(style='ErrorLabel.TLabel')
                self.feedback_label['text'] = "No results found for this netid."
        except URLError:
            self.feedback_label.config(style="ErrorLabel.TLabel")
            self.feedback_label['text'] = "Internet connection disrupted.\n" \
                                          "Try again later when connection\n" \
                                          "is improved. :("
Ejemplo n.º 2
0
 def get_data(self):
     self.member_netID_to_create = self.create_netID_entry.get()
     self.member_major_to_create = self.create_major_entry.get()
     self.member_classification_to_create = self.create_classification_entry.get()
     self.member_name_to_create = self.create_name_entry.get()
     select_sql_string = "SELECT * FROM Member WHERE netID='"+self.member_netID_to_create+"'"
     connection = MIS_Database_Functions.get_connection()
     cursor = connection.cursor()
     cursor.execute(select_sql_string)
     member_data = cursor.fetchone()
     if member_data is None:
         raw_html = Info_IaState_Scraper.get_raw_html(self.member_netID_to_create)
         parsed_data = Info_IaState_Scraper.parse_student_data(raw_html)
         self.create_classification_entry.insert(0, parsed_data['classification'])
         self.create_major_entry.insert(0, parsed_data['major'])
         if 'Individual Search Results' not in parsed_data['name']:
             self.create_name_entry.insert(0, parsed_data['name'])
         self.trial_checkbox.select()
     else:
         self.create_classification_entry.insert(0, member_data[3])
         self.create_major_entry.insert(0, member_data[2])
         self.create_name_entry.insert(0, member_data[4])
         if member_data[5] == 2:
             self.two_semesters_checkbox.select()
         elif member_data[5] == 1:
             self.one_semester_checkbox.select()
         else:
             for i in range(4):
                 self.trial_checkbox.flash()
                 self.one_semester_checkbox.flash()
                 self.two_semesters_checkbox.flash()
Ejemplo n.º 3
0
def create_member(net_id):
    """
    Creates a member instance in the Member table.

    :param net_id: The new member's net id
    :return: void
    """
    #TODO put this exception handling in to the presentation layer
    #if ' ' in net_id or '@' in net_id:
    #    raise Exception('Only enter the first portion of the net id => [email protected] - jmrolf')
    student_html = Info_IaState_Scraper.get_raw_html(net_id)
    student_data = Info_IaState_Scraper.parse_student_data(student_html)
    connection = get_connection()
    cursor = connection.cursor()
    sql_string = "INSERT INTO Member VALUES('"+net_id+"', '"+net_id+"@iastate.edu', " \
                 "'"+student_data['classification']+"', '" + student_data['major']+"', " \
                 "'"+student_data['name']+"', 0)"
    cursor.execute(sql_string)
    connection.commit()
Ejemplo n.º 4
0
    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