From d3c7b244f6b8722fcfe9d00aa20d77d119b5e943 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 05 2015 07:24:44 +0000 Subject: [PATCH 1/7] Add configuration keys for the upload sources feature We need the path to the folder to know where to upload the files We need the name of the folder to point the users to it in the UI We need to blacklist the folder name to avoid people create a project named as such --- diff --git a/pagure/default_config.py b/pagure/default_config.py index 143a7ce..6995985 100644 --- a/pagure/default_config.py +++ b/pagure/default_config.py @@ -89,6 +89,11 @@ GITOLITE_CONFIG = os.path.join( 'gitolite.conf' ) +# Configuration keys to specify where the upload folder is and what is its +# name +UPLOAD_FOLDER = 'releases/' +UPLOAD_FOLDER_PATH = './' + UPLOAD_FOLDER + # Home folder of the gitolite user -- Folder where to run gl-compile-conf from GITOLITE_HOME = None @@ -139,7 +144,7 @@ SHORT_LENGTH = 6 APPLICATION_ROOT = '/' # List of blacklisted project names -BLACKLISTED_PROJECTS = ['static', 'pv'] +BLACKLISTED_PROJECTS = ['static', 'pv', 'releases'] ACLS = { 'issue_create': 'Create a new ticket against this project', From cda607e1de828ff06acfd710c53061fe78d537d9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 05 2015 07:24:44 +0000 Subject: [PATCH 2/7] Add a new endpoint to upload tarballs --- diff --git a/pagure/templates/new_release.html b/pagure/templates/new_release.html new file mode 100644 index 0000000..01761db --- /dev/null +++ b/pagure/templates/new_release.html @@ -0,0 +1,33 @@ +{% extends "repo_master.html" %} + +{% block title %}New release - {{ repo.name }}{% endblock %} +{%block tag %}home{% endblock %} + + +{% block repo %} + +

Upload a new release

+ +

+ You can upload your tarball to pagure. This tarball can be as big as + {{ config['MAX_CONTENT_LENGTH'] / 1024 /1024 }}MB. +

+ +
+{{ form.csrf_token }} + + +
+ +
+
+ +

+ After the upload the source will be available in the + + release folder + . +

+ +{% endblock %} diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 04e4546..259ec5d 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -16,6 +16,7 @@ from math import ceil import flask import pygit2 import kitchen.text.converters as ktc +import werkzeug from cStringIO import StringIO from PIL import Image @@ -640,6 +641,45 @@ def view_tags(repo, username=None): username=username, repo=repo, tags=tags, + admin=is_repo_admin(repo), + ) + + +@APP.route('//releases/new/', methods=('GET', 'POST')) +@APP.route('//releases/new', methods=('GET', 'POST')) +@APP.route('/fork///releases/new/', methods=('GET', 'POST')) +@APP.route('/fork///releases/new', methods=('GET', 'POST')) +def new_release(repo, username=None): + """ Upload a new release. + """ + repo = pagure.lib.get_project(SESSION, repo, user=username) + + if not repo: + flask.abort(404, 'Project not found') + + if not is_repo_admin(repo): + flask.abort( + 403, + 'You are not allowed to change the settings for this project') + + form = pagure.forms.UploadFileForm() + + if form.validate_on_submit(): + filestream = flask.request.files['filestream'] + print filestream + filename = werkzeug.secure_filename(filestream.filename) + filestream.save( + os.path.join(APP.config['UPLOAD_FOLDER_PATH'], filename)) + flask.flash('File uploaded') + return flask.redirect( + flask.url_for('view_tags', repo=repo.name, username=username)) + + return flask.render_template( + 'new_release.html', + select='tags', + username=username, + repo=repo, + form=form, ) From 8a6e874cc1953d860c16145ccc812a9fe225e81a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 05 2015 07:24:44 +0000 Subject: [PATCH 3/7] Add link to upload new release on the tags page --- diff --git a/pagure/templates/tags.html b/pagure/templates/tags.html index 0ddba2e..66ad100 100644 --- a/pagure/templates/tags.html +++ b/pagure/templates/tags.html @@ -3,17 +3,38 @@ {% block title %}Tags - {{ repo.name }}{% endblock %} {%block tag %}home{% endblock %} +{% block header %} + +{% endblock %} {% block repo %}

Tags

+

+ If the developers have upload one or more tarball(s), you will be able to + find them in the + release folder + . +

+ +

+ + + +

+
{% if tags %}