def view_project(project_name): project = Project.find_by_name(project_name) if project is None: return abort(404) project.description = str(project.description) project.categories = [c['category_name'] for c in project.categories] project.requirements = [r['requirement'] for r in project.requirements] has_prev_application = Application.find( project_name=project_name, student_name=current_user.username, ) is not None if request.method == 'POST': if has_prev_application: flash('You can only apply once to each project', 'danger') else: if project.check_user(current_user) is False: flash('You do not fulfill the requirements', 'warning') else: application = Application(project_name=project_name, student_name=current_user.username, application_date=datetime.now(), status='pending', is_new_application=True) application.save() flash('Application successfully submitted!', 'success') try: temp = render_template('view_project.html', project=project, has_prev_application=has_prev_application) except: project.description = '' temp = render_template('view_project.html', project=project, has_prev_application=has_prev_application) return temp
def _decide_application(project_name, student_name, accept): application = Application.find(project_name=project_name, student_name=student_name) if application.status == 'pending': if accept: application.accept() flash('Successfully accepted application', 'success') else: application.reject() flash('Successfully rejected application', 'success') else: flash('Cannot change status of a decided application', 'danger') return redirect(url_for('admin.view_all_applications'))
def view_applications(): my_apps = Application.find(student_name=current_user.username) return render_template('view_applications.html', applications=my_apps)