Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
commit d5d4ce9b7748e142f7199d8fde0b6f9763c8b5e2 Author: Valentin Gologuzov vgologuz@redhat.com Date: Tue Dec 2 11:33:24 2014 +0100
[frontend] presentation: inverted auto_createrepo html presentation; html changes about auto_createrepo
frontend/coprs_frontend/coprs/forms.py | 5 +-- frontend/coprs_frontend/coprs/logic/coprs_logic.py | 4 +- frontend/coprs_frontend/coprs/models.py | 10 +++++ .../coprs/templates/coprs/_coprs_forms.html | 15 +++++--- .../coprs/templates/coprs/detail/overview.html | 38 ++++++++++---------- .../coprs/views/api_ns/api_general.py | 15 ++++++-- .../coprs/views/coprs_ns/coprs_general.py | 5 ++- 7 files changed, 56 insertions(+), 36 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/forms.py b/frontend/coprs_frontend/coprs/forms.py index 538ff92..241a4b2 100644 --- a/frontend/coprs_frontend/coprs/forms.py +++ b/frontend/coprs_frontend/coprs/forms.py @@ -125,10 +125,7 @@ class CoprFormFactory(object): validators=[UrlListValidator()], filters=[StringListFilter()])
- # FIXME: false_values used for API, json API shouldn't not be - # validated in the same way as plain POST requests - auto_createrepo = wtforms.BooleanField( - default=True, false_values=["", "false", False]) + disable_createrepo = wtforms.BooleanField(default=False)
@property def selected_chroots(self): diff --git a/frontend/coprs_frontend/coprs/logic/coprs_logic.py b/frontend/coprs_frontend/coprs/logic/coprs_logic.py index 7613b66..2dba3d0 100644 --- a/frontend/coprs_frontend/coprs/logic/coprs_logic.py +++ b/frontend/coprs_frontend/coprs/logic/coprs_logic.py @@ -128,14 +128,14 @@ class CoprsLogic(object):
@classmethod def add(cls, user, name, repos, selected_chroots, description, - instructions, auto_createrepo, check_for_duplicates=False): + instructions, check_for_duplicates=False, **kwargs): copr = models.Copr(name=name, repos=repos, owner=user, description=description, instructions=instructions, created_on=int(time.time()), - auto_createrepo=auto_createrepo) + **kwargs)
# form validation checks for duplicates CoprsLogic.new(user, copr, diff --git a/frontend/coprs_frontend/coprs/models.py b/frontend/coprs_frontend/coprs/models.py index 111a092..dc3239d 100644 --- a/frontend/coprs_frontend/coprs/models.py +++ b/frontend/coprs_frontend/coprs/models.py @@ -179,6 +179,16 @@ class Copr(db.Model, helpers.Serializer):
return len(self.builds)
+ @property + def disable_createrepo(self): + + return not self.auto_createrepo + + @disable_createrepo.setter + def disable_createrepo(self, value): + + self.auto_createrepo = not bool(value) + def check_copr_chroot(self, chroot): """ Return object of chroot, if is related to our copr or None diff --git a/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html b/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html index 81c9193..0165f39 100644 --- a/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html +++ b/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html @@ -59,15 +59,18 @@ {{ render_field(form.initial_pkgs, rows=5, cols=50, placeholder='Optional - list of src.rpm to build initially. Can be skipped and submitted later.') }} {% endif %}
- <dt class="field-label"> - <label for="auto_createrepo">Build release options</label> - </dt> + <dt><b>Package repositories</b></dt> + <dd class="field-label-help"> + Repository meta data is refreshed after each build. <br /> + You can disable it with the option below. <br /> + You will be still able to regenerate your repositories manually on the overview page. + </dd> <dd> - Create repository metadata automatically: - {{ form.auto_createrepo }} + <!-- Create repository metadata automatically: --> + Disable automatic repository meta data generation + {{ form.disable_createrepo }} </dd>
- <dt><input type="submit" value="{% if copr %}Update{% else %}Create{% endif %}"></dt> </dl> </form> diff --git a/frontend/coprs_frontend/coprs/templates/coprs/detail/overview.html b/frontend/coprs_frontend/coprs/templates/coprs/detail/overview.html index a88dc9a..6f02e8c 100644 --- a/frontend/coprs_frontend/coprs/templates/coprs/detail/overview.html +++ b/frontend/coprs_frontend/coprs/templates/coprs/detail/overview.html @@ -50,11 +50,12 @@ <a id="modified-chroot-{{mock_chroot.name}}">[modified]</a> {% endif %} </td> + <td> {% if mock_chroot.os_release != copr.active_chroots[loop.index0 - 1].os_release or mock_chroot.os_version != copr.active_chroots[loop.index0 - 1].os_version or loop.index0 == 0 %} {# previous os_release-os_version were different or this is the first one #} - <td> + <a href="{{ url_for( 'coprs_ns.generate_repo_file', @@ -66,11 +67,8 @@ )|fix_url_https_frontend}}"> {{ copr.owner.name }}-{{ copr.name }}-{{mock_chroot.os_release+"-"+mock_chroot.os_version}}.repo </a> - </td> - {% else %} - <td></td> {% endif %} - + </td> </tr> {% else %} <tr colspan="2"><td>No active releases</td></tr> @@ -85,21 +83,23 @@ </ul> {% endif %}
- {% if g.user and g.user.can_edit(copr) and not copr.auto_createrepo %} - <div> - - <h2>Release options</h2> + {% if g.user and g.user.can_edit(copr) and copr and copr.owner and not copr.auto_createrepo %} + <dt> + <!--<h2>Release options</h2>--> + </dt> + <dd> + <form action="{{ + url_for( + 'coprs_ns.copr_createrepo', + username=copr.owner.name, + coprname=copr.name + ) }}" method="post" >
- <form action="{{ - url_for( - 'coprs_ns.copr_createrepo', - username=copr.owner.name, - coprname=copr.name - ) }}" method="post" > - Create repository metodata forcible: - <button type="submit">Run createrepo</button> - </form> - </div> + Automatic repository meta data generation is disabled. + You can regenerate it manually or enable the automatic refresh on the edit page. + <button type="submit">Regenerate repositories</button> + </form> + </dd> {% endif %}
{% for chroot in copr.modified_chroots %} diff --git a/frontend/coprs_frontend/coprs/views/api_ns/api_general.py b/frontend/coprs_frontend/coprs/views/api_ns/api_general.py index cae3495..faf08cc 100644 --- a/frontend/coprs_frontend/coprs/views/api_ns/api_general.py +++ b/frontend/coprs_frontend/coprs/views/api_ns/api_general.py @@ -1,5 +1,6 @@ import base64 import datetime +import json import urlparse
import flask @@ -72,6 +73,7 @@ def api_new_copr(username): httpcode = 200
# are there any arguments in POST which our form doesn't know? + # TODO: don't use WTFform for parsing and validation here if any([post_key not in form.__dict__.keys() for post_key in flask.request.form.keys()]): output = {"output": "notok", @@ -80,9 +82,16 @@ def api_new_copr(username):
elif form.validate_on_submit(): infos = [] - auto_createrepo = form.auto_createrepo.data - if "auto_createrepo" not in flask.request.data: - auto_createrepo = True + + auto_createrepo = True + dct = json.loads(flask.request.data) + if "auto_createrepo" in dct: + val = dct["auto_createrepo"] + if isinstance(val, bool): + auto_createrepo = val + elif str(val).lower() in ["false", "no"]: + auto_createrepo = False + try: copr = coprs_logic.CoprsLogic.add( name=form.name.data.strip(), 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 85ddc3d..c5e765b 100644 --- a/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py +++ b/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py @@ -133,7 +133,7 @@ def copr_new(username): selected_chroots=form.selected_chroots, description=form.description.data, instructions=form.instructions.data, - auto_createrepo=form.auto_createrepo.data, + disable_createrepo=form.disable_createrepo.data, )
db.session.commit() @@ -257,7 +257,7 @@ def copr_update(username, coprname): copr.repos = form.repos.data.replace("\n", " ") copr.description = form.description.data copr.instructions = form.instructions.data - copr.auto_createrepo = form.auto_createrepo.data + copr.disable_createrepo = form.disable_createrepo.data coprs_logic.CoprChrootsLogic.update_from_names( flask.g.user, copr, form.selected_chroots)
@@ -414,6 +414,7 @@ def copr_createrepo(username, coprname): chroots=chroots)
db.session.commit() + flask.flash("Repository metadata will be regenerated in a few minutes ...") return flask.redirect(flask.url_for("coprs_ns.copr_detail", username=copr.owner.name, coprname=copr.name))
copr-commits@lists.fedorahosted.org