diff options
author | rubenwardy <rw@rubenwardy.com> | 2018-03-20 18:40:19 +0000 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2018-03-20 18:40:19 +0000 |
commit | d03947462dc283588cada03a8456fe03233c0f2d (patch) | |
tree | 5d6b5744ab456f95b8a74d46906ec6f22637da4b /app/views/packages.py | |
parent | 596f725d599f15b222d7ce2dcfc5b6a76aebb3e8 (diff) | |
download | cheatdb-d03947462dc283588cada03a8456fe03233c0f2d.tar.xz |
Add create release page
Diffstat (limited to 'app/views/packages.py')
-rw-r--r-- | app/views/packages.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/views/packages.py b/app/views/packages.py index d6b6e69..4543503 100644 --- a/app/views/packages.py +++ b/app/views/packages.py @@ -85,3 +85,35 @@ def edit_package_page(type, author, name): return redirect(package.getDetailsURL()) # redirect return render_template('package_edit.html', package=package, form=form) + + +class PackageReleaseForm(FlaskForm): + name = StringField("Name") + title = StringField("Title") + uploadOpt = RadioField ("File", choices=[("vcs", "From VCS Commit or Branch"), ("upload", "File Upload")]) + vcsLabel = StringField("VCS Commit or Branch", default="master") + fileUpload = FileField("File Upload") + submit = SubmitField('Save') + +@app.route("/<type>s/<author>/<name>/releases/new/", methods=['GET', 'POST']) +@login_required +def create_release_page(type, author, name): + package = getPageByInfo(type, author, name) + if not package.checkPerm(current_user, Permission.MAKE_RELEASE): + return redirect(package.getDetailsURL()) + + # Initial form class from post data and default data + form = PackageReleaseForm(formdata=request.form) + if request.method == "POST" and form.validate(): + if form["uploadOpt"].data == "vcs": + rel = PackageRelease() + rel.package = package + rel.title = form["title"].data + rel.url = form["vcsLabel"].data + # TODO: get URL to commit from branch name + db.session.commit() + return redirect(package.getDetailsURL()) # redirect + else: + raise Exception("Unimplemented option = file upload") + + return render_template('package_release_new.html', package=package, form=form) |