Beispiel #1
0
def finder_user():
    username = str(request.form.get('username', ''))
    new_user = user.find_user(username)
    if user.find_user(username):
        return render_template('finduser.html', new_user=new_user)
    flash("Sorry,没有查到相关数据!")
    return render_template('finduser.html')
Beispiel #2
0
    def post(self, token):
        self.head()
        self.response.headers['Content-Type'] = 'text/html'

        if not user.validate_user(
                self) or self.request._user.status != 'staff':
            self.response.write('Only staff members can submit scores.')
            return

        email = self.request.get('email').strip()
        assignment = self.request.get('assignment').strip()
        action = self.request.get('action').strip()
        value = self.request.get('value').strip()
        notes = self.request.get('notes').strip()
        logging.info('email: ' + email)

        message = ''
        u = user.find_user(None, email=email)
        if len(action) != 0:
            if u is None:
                message = "User %s doesn't exist." % email
            else:
                score = Score(subject=course.subject,
                              email=email,
                              submitter=self.request._email,
                              assignment=assignment,
                              action=action,
                              value=value,
                              notes=notes)
                score.put()

        # display a form for editing user info
        template_file = 'templates/submit_score.html'
        template_info = {
            'url':
            self.request.url.split('?')[0],  # strip argument(s), if any
            'status_url':
            self.request.url[:self.request.url.find('/grades/submit_score')],
            'message':
            message,
            'user':
            u,
            'assignments':
            course.assignments,
            'actions':
            get_scores(email),
        }

        path = os.path.join(os.path.dirname(__file__), template_file)
        self.response.write(template.render(path, template_info))
Beispiel #3
0
    def post(self,token):
        self.head()
        self.response.headers['Content-Type'] = 'text/html'

        if not user.validate_user(self) or self.request._user.status != 'staff':
            self.response.write('Only staff members can submit scores.')
            return

        email = self.request.get('email').strip()
        assignment = self.request.get('assignment').strip()
        action = self.request.get('action').strip()
        value = self.request.get('value').strip()
        notes = self.request.get('notes').strip()
        logging.info('email: '+email)

        message = ''
        u = user.find_user(None,email=email)
        if len(action) != 0:
            if u is None:
                message = "User %s doesn't exist." % email
            else:
                score = Score(subject = course.subject,
                              email = email,
                              submitter = self.request._email,
                              assignment = assignment,
                              action = action,
                              value = value,
                              notes = notes)
                score.put()

        # display a form for editing user info
        template_file = 'templates/submit_score.html'
        template_info = {
            'url': self.request.url.split('?')[0],   # strip argument(s), if any
            'status_url': self.request.url[:self.request.url.find('/grades/submit_score')],
            'message': message,
            'user': u,
            'assignments': course.assignments,
            'actions': get_scores(email),
        }

        path = os.path.join(os.path.dirname(__file__), template_file)
        self.response.write(template.render(path,template_info))
Beispiel #4
0
    menu = input("Enter the number > ")

    if menu == '5':
        break

    if menu == "1":
        clear_screen()
        add_user_from_csv = input("Do you want to add a user from a csv? (\'yes\' or \'no\') ").lower()

        if add_user_from_csv == 'yes':
            print("Which user you want to add? (Enter the ID): \nID - Name")
            print(user.print_users())

            input_user_id = input('> ')

            name = user.find_user(input_user_id)
            user.add_user(name)
        elif add_user_from_csv == 'no':
            input_name = input("What's the user's full name? ")
            user.add_user(input_name)
        else:
            print("Please answer \'yes\' or \'no\'")
    elif menu == "2":
        clear_screen()
        user.delete_user()
    elif menu == '3':
        clear_screen()
        user.modify_user()
    elif menu == '4':
        clear_screen()
        user.reset_password()