[copr] master: frontend: give nice error instead of traceback (b83a08c)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit b83a08c236c353e636a3374501e4e3cc10ccdefc
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Mar 6 21:06:23 2014 +0100
frontend: give nice error instead of traceback
addressing:
Exception on /coprs/rhscl/python27/delete/ [POST]
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python2.7/site-packages/flask/app.py", line 1344, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/share/copr/coprs_frontend/coprs/views/misc.py", line 131, in decorated_function
return f(*args, **kwargs)
File "/usr/share/copr/coprs_frontend/coprs/views/coprs_ns/coprs_general.py", line 322, in copr_delete
coprs_logic.CoprsLogic.delete(flask.g.user, copr)
File "/usr/share/copr/coprs_frontend/coprs/logic/coprs_logic.py", line 162, in delete
cls.raise_if_cant_delete(user, copr)
File "/usr/share/copr/coprs_frontend/coprs/logic/coprs_logic.py", line 227, in raise_if_cant_delete
if not user.admin and user != copr.owner:
AttributeError: 'NoneType' object has no attribute 'owner'
>---------------------------------------------------------------
.../coprs/views/coprs_ns/coprs_general.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
index 09de72a..cf56e12 100644
--- a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
+++ b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
@@ -317,7 +317,7 @@ def copr_delete(username, coprname):
form = forms.CoprDeleteForm()
copr = coprs_logic.CoprsLogic.get(flask.g.user, username, coprname).first()
- if form.validate_on_submit():
+ if form.validate_on_submit() and copr:
try:
coprs_logic.CoprsLogic.delete(flask.g.user, copr)
except (exceptions.ActionInProgressException,
10 years, 2 months
[copr] master: setup guide fix (471d391)
by asamalik@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 471d3917fb0ecae797998c5798f9a0f448ab4b6a
Author: Adam Samalik <asamalik(a)redhat.com>
Date: Wed Mar 5 17:44:32 2014 +0100
setup guide fix
>---------------------------------------------------------------
copr-setup.txt | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/copr-setup.txt b/copr-setup.txt
index 58ca735..de784c9 100644
--- a/copr-setup.txt
+++ b/copr-setup.txt
@@ -53,7 +53,7 @@ Frontend:
- yum install copr-frontend copr-selinux
- apache setup
- cp /usr/share/doc/copr-frontend-*/coprs.conf.example /etc/httpd/conf.d/coprs.conf
+ cp /usr/share/doc/copr-frontend/coprs.conf.example /etc/httpd/conf.d/coprs.conf
and edit it to your needs - at least ServerName, port and WSGIScriptAlias
- if you run on EPEL add virtenv of flask and friends
@@ -63,7 +63,7 @@ Frontend:
- pip install -I SQLAlchemy MarkupSafe
- pip install pytest
-- edit credentials /etc/copr/copr.conf (or /etc/copr/copr-devel.conf for development mode)
+- edit credentials /etc/copr/copr.conf (or /etc/copr/copr_devel.conf for development mode)
- cd /usr/share/copr/coprs_frontend
- configure DB first - see DB section below
# for develop setup do:
10 years, 2 months
[copr] api_search: api: implement search (5f785d7)
by Igor Gnatenko
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : api_search
>---------------------------------------------------------------
commit 5f785d72fcfa4ee063ad8dbff759324a23cca871
Author: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
Date: Sun Feb 16 17:38:59 2014 +0400
api: implement search
Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1064118
Signed-off-by: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
>---------------------------------------------------------------
coprs_frontend/coprs/templates/api.html | 49 ++++++++++++++++++++++
coprs_frontend/coprs/views/api_ns/api_general.py | 30 +++++++++++++
2 files changed, 79 insertions(+), 0 deletions(-)
diff --git a/coprs_frontend/coprs/templates/api.html b/coprs_frontend/coprs/templates/api.html
index e835d0f..1df4fb3 100644
--- a/coprs_frontend/coprs/templates/api.html
+++ b/coprs_frontend/coprs/templates/api.html
@@ -333,5 +333,54 @@ copr_url = http://copr.fedoraproject.org
}
</pre>
+ <h3>Search for project</h3>
+
+ <h4>URL:</h4>
+ <pre style="font-size:120%">/api/coprs/search/<project>/</pre>
+ <div>or</div>
+ <pre style="font-size:120%">/api/coprs/?search="<project>"</pre>
+
+ <h4>URL parameters:</h4>
+ <ul>
+ <li><b>project</b> – The text of the project whose you'd like
+ to find</li>
+ </ul>
+
+ <h4>Result:</h4>
+ <ul>
+ <li><b>"repos"</b> – List of repos in given format:
+ <ul>
+ <li><b>"username"</b> – Name of the user</li>
+ <li><b>"coprname"</b> – Name of the copr</li>
+ <li><b>"description"</b> – Description of the copr</li>
+ </ul>
+ </ul>
+
+ <h4>Example call URL</h4>
+ <pre style="font-size:120%">https://copr.fedoraproject.org/api/coprs/search/tests/</pre>
+
+ <h4>Example results</h4>
+ <pre>
+ {
+ "output": "ok",
+ "repos": [
+ {
+ "username": "ignatenkobrain",
+ "coprname": "test",
+ "description": "Tests"
+ },
+ "username": "ignatenkobrain",
+ "coprname": "tests",
+ "description": ""
+ },
+ {
+ "username": "msuchy",
+ "coprname": "tests",
+ "description": "Copr testing repository, just for test various builds."
+ }
+ ]
+ }
+ </pre>
+
</div>
{% endblock %}
diff --git a/coprs_frontend/coprs/views/api_ns/api_general.py b/coprs_frontend/coprs/views/api_ns/api_general.py
index 0a673d2..cc41fdd 100644
--- a/coprs_frontend/coprs/views/api_ns/api_general.py
+++ b/coprs_frontend/coprs/views/api_ns/api_general.py
@@ -340,3 +340,33 @@ def copr_chroot_details(username, coprname, chrootname):
jsonout = flask.jsonify(output)
jsonout.status_code = httpcode
return jsonout
+
+(a)api_ns.route("/coprs/search/")
+(a)api_ns.route("/coprs/search/<project>/")
+def api_coprs_search_by_project(project=None):
+ """ Return the list of coprs found in search by the given text.
+ project is taken either from GET params or from the URL itself
+ (in this order).
+
+ :arg project: the text one would like find for coprs.
+
+ """
+ project = flask.request.args.get("project", None) or project
+ httpcode = 200
+ if project:
+ query = coprs_logic.CoprsLogic.get_multiple_fulltext(
+ flask.g.user, project)
+
+ repos = query.all()
+ output = {"output": "ok", "users": []}
+ for repo in repos:
+ output["repos"].append({"username": repo.owner,
+ "coprname"; repo.name,
+ "description": repo.description})
+ else:
+ output = {"output": "notok", "error": "Invalid request"}
+ httpcode = 500
+
+ jsonout = flask.jsonify(output)
+ jsonout.status_code = httpcode
+ return jsonout
10 years, 2 months
[copr] master: dnf-plugin: delete excess argument (21b2f6e)
by Igor Gnatenko
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 21b2f6e8450c313a2baf989baf7eed542200ce71
Author: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
Date: Mon Mar 3 22:11:18 2014 +0400
dnf-plugin: delete excess argument
Reported-by: Miroslav Suchý <msuchy(a)redhat.com>
Signed-off-by: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
>---------------------------------------------------------------
dnf-plugin/copr_hook.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/dnf-plugin/copr_hook.py b/dnf-plugin/copr_hook.py
index 1c26c67..89327b6 100644
--- a/dnf-plugin/copr_hook.py
+++ b/dnf-plugin/copr_hook.py
@@ -85,7 +85,7 @@ list name""")
if "Fedora" in dist:
chroot = ("fedora-%s-x86_64" % dist[2].lower() if "Rawhide" in dist else dist[1])
else:
- chroot = ("epel-%s-x86_64" % dist[1].split(".", 1)[0], arch)
+ chroot = ("epel-%s-x86_64" % dist[1].split(".", 1)[0])
repo_filename = "/etc/yum.repos.d/_copr_{}.repo".format(project_name.replace("/", "-"))
base_url = "http://copr.fedoraproject.org"
if subcommand == "enable":
10 years, 2 months
[copr] master: 1063311 - admin should be able to delete task (7c48726)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 7c48726671267e7b67f2413e864fd229fbe5f79c
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Mar 3 14:29:26 2014 +0100
1063311 - admin should be able to delete task
>---------------------------------------------------------------
coprs_frontend/coprs/logic/builds_logic.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/coprs_frontend/coprs/logic/builds_logic.py b/coprs_frontend/coprs/logic/builds_logic.py
index b449ff3..44d0ead 100644
--- a/coprs_frontend/coprs/logic/builds_logic.py
+++ b/coprs_frontend/coprs/logic/builds_logic.py
@@ -139,16 +139,16 @@ class BuildsLogic(object):
@classmethod
def cancel_build(cls, user, build):
- if build.user_id != user.id:
+ if not (user.can_build_in(build.copr):
raise exceptions.InsufficientRightsException(
- "You can only cancel your own builds.")
+ "You are not allowed to cancel this build.")
build.canceled = True
@classmethod
def delete_build(cls, user, build):
- if build.user_id != user.id:
+ if not (user.can_build_in(build.copr):
raise exceptions.InsufficientRightsException(
- "You can only delete your own builds.")
+ "You are not allowed to delete this build.")
action = models.Action(action_type=helpers.ActionTypeEnum("delete"),
object_type="build",
10 years, 2 months
[copr] master: add license header (c198581)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit c198581357587b0c8a3ecb1d140f267a2e08a739
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Mar 3 14:04:49 2014 +0100
add license header
>---------------------------------------------------------------
dnf-plugin/copr_hook.py | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/dnf-plugin/copr_hook.py b/dnf-plugin/copr_hook.py
index eeddc8c..1c26c67 100644
--- a/dnf-plugin/copr_hook.py
+++ b/dnf-plugin/copr_hook.py
@@ -1,3 +1,22 @@
+# supplies the 'copr' command.
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+
import dnf
import os
import sys
10 years, 2 months