def modify(notice_id): try: notice = queries.get_notice(notice_id) if request.method == 'GET': title = urldecode(notice.title) content = urldecode(notice.content) errors = [] else: title = request.form['title'].strip() content = request.form['content'].strip() errors = [] if title == u'' or title == '': errors.append('제목이 없습니다.') if content == u'' or content == '': errors.append('내용이 없습니다.') if len(errors) == 0: queries.modify_notice(notice, title, content) return redirect(url_for('notice.list')) return render_template('notice_modify.html', notice_id=notice.id, title=title, content=content, errors=errors) except Exception, e: print e return redirect(url_for('notice.list'))
def modify(user_id): try: user = queries.get_user(user_id) if user.active == False: raise if request.method == 'GET': name = urldecode(user.name) birthday = urldecode(user.birthday) phone = urldecode(user.phone) point = user.point photo = user.photo errors = [] else: name = request.form['name'].strip() birthday = request.form['birthday'].strip() phone = request.form['phone'].strip() point = request.form['point'].strip() photo = user.photo errors = [] if name == u'' or name == '': errors.append('이름이 빈칸입니다.') if birthday == u'' or birthday == '': errors.append('생일이 빈칸입니다.') if phone == u'' or phone == '': errors.append('전화번호가 빈칸입니다.') try: point = int(point) except: errors.append('골프공의 수는 정수여야합니다.') if len(errors) == 0: queries.modify_user(user, name, birthday, phone, point) return redirect(url_for('user.list')) return render_template('user_modify.html', name=name, birthday=birthday, phone=phone, point=point, photo=photo, user_id=user_id, errors=errors) except Exception, e: print e return redirect(url_for('user.list'))
def modify(teacher_id): try: teacher = queries.get_teacher(teacher_id) if teacher.active == False: raise if request.method == 'GET': name = urldecode(teacher.name) birthday = urldecode(teacher.birthday) phone = urldecode(teacher.phone) company = urldecode(teacher.company) certification = urldecode(teacher.certification) price = teacher.price photo = teacher.photo profile = urldecode(teacher.profile) url = urldecode(teacher.url) errors = [] else: name = request.form['name'].strip() birthday = request.form['birthday'].strip() phone = request.form['phone'].strip() company = request.form['company'].strip() certification = request.form['certification'].strip() price = request.form['price'].strip() profile = request.form['profile'].strip() url = request.form['url'].strip() if 'photo' in request.files and request.files['photo']: photo = request.files['photo'] photo_name = 'teacher_' + str(teacher_id) + '_' + str(get_timestamp()) + '.png' photo_path = os.path.join(current_app.config['PROFILE_FOLDER'], photo_name) photo.save(photo_path) photo = photo_name else: photo = None errors = [] if name == u'' or name == '': errors.append('이름이 빈칸입니다.') if birthday == u'' or birthday == '': errors.append('생일이 빈칸입니다.') if phone == u'' or phone == '': errors.append('전화번호가 빈칸입니다.') if company == u'' or company == '': errors.append('회사이름이 빈칸입니다.') if certification == u'' or certification == '': errors.append('자격증이 빈칸입니다.') try: price = int(price) if price % 100 != 0: errors.append('금액은 100의 배수여야 합니다.') except: errors.append('금액은 정수여야합니다.') if len(errors) == 0: queries.modify_teacher(teacher, name, birthday, phone, photo, company, \ certification, True, price, profile, url) return redirect(url_for('teacher.list')) return render_template('teacher_modify.html', name=name, birthday=birthday, phone=phone, company=company, certification=certification, price=price, profile=profile, url=url, photo=photo, errors=errors, teacher_id=teacher_id, status=teacher.status) except Exception, e: print e return redirect(url_for('teacher.list'))