This is an automated email from the git hooks/post-receive script.
praiskup pushed a commit to branch master in repository copr/copr.
The following commit(s) were added to refs/heads/master by this push: new 08b4849 frontend: add option to comment on chroots 08b4849 is described below
commit 08b4849e7e731804cd715719e542c3fff0efcff1 Author: Dominik Turecek dturecek@redhat.com AuthorDate: Mon Sep 9 12:53:22 2019 +0200
frontend: add option to comment on chroots
Merges: #853 --- ...800e08934eb_add_comment_to_mock_chroot_table.py | 20 +++++++++++++++++++ frontend/coprs_frontend/commands/comment_chroot.py | 23 ++++++++++++++++++++++ frontend/coprs_frontend/coprs/models.py | 2 ++ .../coprs/templates/coprs/_coprs_forms.html | 7 +++++-- .../templates/coprs/detail/settings/edit.html | 2 +- .../coprs/views/coprs_ns/coprs_general.py | 7 +++++-- frontend/coprs_frontend/manage.py | 1 + 7 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/frontend/coprs_frontend/alembic/schema/versions/6800e08934eb_add_comment_to_mock_chroot_table.py b/frontend/coprs_frontend/alembic/schema/versions/6800e08934eb_add_comment_to_mock_chroot_table.py new file mode 100644 index 0000000..7c1dd56 --- /dev/null +++ b/frontend/coprs_frontend/alembic/schema/versions/6800e08934eb_add_comment_to_mock_chroot_table.py @@ -0,0 +1,20 @@ +""" +add comment to mock_chroot table + +Revision ID: 6800e08934eb +Revises: 12abab545d7a +Create Date: 2019-07-30 08:49:53.205823 +""" + +import sqlalchemy as sa +from alembic import op + + +revision = '6800e08934eb' +down_revision = '12abab545d7a' + +def upgrade(): + op.add_column('mock_chroot', sa.Column('comment', sa.Text, nullable=True)) + +def downgrade(): + op.drop_column('mock_chroot', 'comment') diff --git a/frontend/coprs_frontend/commands/comment_chroot.py b/frontend/coprs_frontend/commands/comment_chroot.py new file mode 100644 index 0000000..a29e8a9 --- /dev/null +++ b/frontend/coprs_frontend/commands/comment_chroot.py @@ -0,0 +1,23 @@ +from flask_script import Command, Option +from coprs import db +from coprs.logic.coprs_logic import MockChrootsLogic + + +class CommentChrootCommand(Command): + + """ + Add comment to a mock_chroot. + """ + + def run(self, chrootname, comment): + chroot = MockChrootsLogic.get_from_name(chrootname).first() + if not chroot: + print("There is no mock chroot named {0}.".format(chrootname)) + return + chroot.comment = comment + db.session.commit() + + option_list = ( + Option("chrootname"), + Option("comment"), + ) diff --git a/frontend/coprs_frontend/coprs/models.py b/frontend/coprs_frontend/coprs/models.py index 9f89fc7..42d7542 100644 --- a/frontend/coprs_frontend/coprs/models.py +++ b/frontend/coprs_frontend/coprs/models.py @@ -1183,6 +1183,8 @@ class MockChroot(db.Model, helpers.Serializer): # will skip all projects using this chroot final_prunerepo_done = db.Column(db.Boolean, default=False, server_default="0", nullable=False)
+ comment = db.Column(db.Text, nullable=True) + @classmethod def latest_fedora_branched_chroot(cls, arch='x86_64'): return (cls.query diff --git a/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html b/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html index 47f114e..9ce1c83 100644 --- a/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html +++ b/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html @@ -1,6 +1,6 @@ {% from "_helpers.html" import render_field, render_checkbox_field, render_form_errors, copr_details_href, copr_url %}
-{% macro copr_form(form, view, copr = None, username = None, group = None) %} +{% macro copr_form(form, view, copr = None, username = None, group = None, comments = None) %} {# if using for updating, we need to pass name to url_for, but otherwise we need to pass nothing #}
{{ render_form_errors(form) }} @@ -67,12 +67,15 @@ <label> {{ form|attr(ch) }} {{ form|attr(ch)|attr('label') }} + {% set chrootname = form|attr(ch)|attr('label')|attr('text') %} {% if copr and form|attr(ch)|attr('data') %} - {% set chrootname = form|attr(ch)|attr('label')|attr('text') %} <a style="margin-left:20px" class="btn btn-xs btn-default" href="{{ copr_url('coprs_ns.chroot_edit', copr, chrootname = chrootname)}}"> <span class="pficon pficon-edit"> Edit </span> </a> {% endif %} + {% if comments[chrootname] %} + <small class="text-muted"> {{ comments[chrootname] }} </small> + {% endif %} </label> </div> {% endfor %}{% endfor %} diff --git a/frontend/coprs_frontend/coprs/templates/coprs/detail/settings/edit.html b/frontend/coprs_frontend/coprs/templates/coprs/detail/settings/edit.html index a77ff73..01e369f 100644 --- a/frontend/coprs_frontend/coprs/templates/coprs/detail/settings/edit.html +++ b/frontend/coprs_frontend/coprs/templates/coprs/detail/settings/edit.html @@ -8,6 +8,6 @@
<h2> Project Details </h2> <p> Edit project information and build settings. </p> -{{ copr_form(form, view=view, copr=copr) }} +{{ copr_form(form, view=view, copr=copr, comments=comments) }}
{% endblock %} diff --git a/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py b/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py index 33517da..774b058 100644 --- a/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py +++ b/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py @@ -28,7 +28,7 @@ from coprs import forms from coprs import helpers from coprs import models from coprs.exceptions import ObjectNotFound -from coprs.logic.coprs_logic import CoprsLogic, PinnedCoprsLogic +from coprs.logic.coprs_logic import CoprsLogic, PinnedCoprsLogic, MockChrootsLogic from coprs.logic.stat_logic import CounterStatLogic from coprs.logic.modules_logic import ModulesLogic, ModulemdGenerator, ModuleBuildFacade from coprs.rmodels import TimedStatEvents @@ -421,9 +421,12 @@ def render_copr_edit(copr, form, view): if not form: form = forms.CoprFormFactory.create_form_cls( copr.mock_chroots, copr=copr)(obj=copr) + comments = {} + for chroot in MockChrootsLogic.get_multiple(active_only=True): + comments[chroot.name] = chroot.comment return flask.render_template( "coprs/detail/settings/edit.html", - copr=copr, form=form, view=view) + copr=copr, form=form, view=view, comments=comments)
@coprs_ns.route("/<username>/<coprname>/edit/") diff --git a/frontend/coprs_frontend/manage.py b/frontend/coprs_frontend/manage.py index 3701370..add5afb 100755 --- a/frontend/coprs_frontend/manage.py +++ b/frontend/coprs_frontend/manage.py @@ -24,6 +24,7 @@ commands = { "display_chroots": "DisplayChrootsCommand", "drop_chroot": "DropChrootCommand", "branch_fedora": "BranchFedoraCommand", + "comment_chroot": "CommentChrootCommand",
# User commands "alter_user": "AlterUserCommand",
copr-commits@lists.fedorahosted.org