dist_templates_DATA = \
src/templates/base.html \
- src/templates/distro-edit.html \
src/templates/distro-source-commit-detail.html \
src/templates/distro-source-commit-reset.html \
src/templates/distro-source-commits.html \
templates_builds_modulesdir = $(templates_buildsdir)/modules
dist_templates_distros_DATA = \
+ src/templates/distros/edit.html \
src/templates/distros/index.html \
src/templates/distros/show.html
return lines
- @property
- def name(self):
+ # Name
+
+ def get_name(self):
return self.data.name
+ def set_name(self, name):
+ self._set_attribute("name", name)
+
+ name = property(get_name, set_name)
+
+ # Slug
+
@property
def slug(self):
return self.data.slug
- @property
- def slogan(self):
+ # Slogan
+
+ def get_slogan(self):
return self.data.slogan
- @property
- def description(self):
+ def set_slogan(self, slogan):
+ self._set_attribute("slogan", slogan or "")
+
+ slogan = property(get_slogan, set_slogan)
+
+ # Description
+
+ def get_description(self):
return self.data.description
+ def set_description(self, description):
+ self._set_attribute("description", description or "")
+
+ description = property(get_description, set_description)
+
# Arches
def get_arches(self):
arches = property(get_arches, set_arches)
- @property
- def vendor(self):
+ # Vendor
+
+ def get_vendor(self):
return self.data.vendor
+ def set_vendor(self, vendor):
+ self._set_attribute("vendor", vendor)
+
+ vendor = property(get_vendor, set_vendor)
+
+ # Contact
+
def get_contact(self):
return self.data.contact
contact = property(get_contact, set_contact)
- def get_tag(self):
- return self.data.tag
-
- def set_tag(self, tag):
- self._set_attribute("tag", tag)
+ # Tag
- tag = property(get_tag, set_tag)
+ @property
+ def tag(self):
+ return self.data.tag
# Custom Configuration
custom_config = property(get_custom_config, set_custom_config)
+ # Permissions
+
+ def has_perm(self, user):
+ # Anonymous users have no permissions
+ if not user:
+ return False
+
+ # Must be admin
+ return user.is_admin()
+
@lazy_property
def repos(self):
repos = self.backend.repos._get_repositories("""
+++ /dev/null
-{% extends "base.html" %}
-
-{% block title %}{{ _("Edit distribution %s") % distro.name }}{% end block %}
-
-{% block body %}
- <h1>{{ _("Edit distribution %s") % distro.name }}</h1>
-
- <form method="post" action="">
- {% raw xsrf_form_html() %}
- <table class="form form3">
- <tr>
- <td class="col1">{{ _("Name") }}</td>
- <td class="col2">
- <input type="text" name="name" value="{{ distro.name }}" />
- </td>
- <td class="col3">
- {{ _("The fancy name of the distribution.") }}
- </td>
- </tr>
- <tr>
- <td class="col1">{{ _("Identifier") }}</td>
- <td class="col2">
- {{ distro.sname }}
- </td>
- <td class="col3">
- {{ _("Cannot be changed.") }}
- </td>
- </tr>
- <tr>
- <td class="col1">{{ _("Tag") }}</td>
- <td class="col2">
- <input type="text" name="tag" value="{{ distro.tag }}" />
- </td>
- <td class="col3">
- {{ _("The tag is added to the package release.") }}
- </td>
- </tr>
- <tr>
- <td class="col1">{{ _("Vendor") }}</td>
- <td class="col2">
- <input type="text" name="vendor" value="{{ distro.vendor }}" />
- </td>
- <td class="col3">
- {{ _("From whom is the distribution from?") }}
- </td>
- </tr>
- <tr>
- <td class="col1">{{ _("Contact") }}</td>
- <td class="col2">
- <input type="text" name="contact" value="{{ distro.contact or "" }}" />
- </td>
- <td>
- {{ _("The email address from the vendor.") }}
- </td>
- </tr>
- <tr>
- <td class="col1">{{ _("Slogan") }}</td>
- <td class="col2">
- <input type="text" name="slogan" value="{{ distro.slogan }}" />
- </td>
- <td class="col3">
- {{ _("A short sentence that characterizes the distribution.") }}
- </td>
- </tr>
- <tr>
- <td class="col1">{{ _("Architectures") }}</td>
- <td class="col2">
- <select name="arches" size="4" multiple>
- {% for arch in arches %}
- <option value="{{ arch }}" {% if arch in distro.arches %}selected{% end %}>{{ arch }}</option>
- {% end %}
- </select>
- </td>
- <td class="col3">
- {{ _("For which architectures should the distribution be built?") }}
- </td>
- </tr>
- <tr>
- <td class="col1">{{ _("Sources") }}</td>
- <td class="col2">
- <select name="sources" size="4" multiple>
- {% for source in sources %}
- <option value="{{ source.id }}" {% if source in distro.sources %}selected="selected"{% end %}>{{ source.name }}</option>
- {% end %}
- </select>
- </td>
- <td class="col3">
- {{ _("Which sources should be imported to the distribution?") }}
- </td>
- </tr>
- <tr>
- <td colspan="3" class="buttons">
- <input type="submit" value="{{ _("Save") }}" />
- </td>
- </tr>
- </table>
- <div style="clear: both;"> </div>
- </form>
-{% end block %}
--- /dev/null
+{% extends "../base.html" %}
+
+{% block title %}{{ _("Distributions") }} - {{ distro }} - {{ _("Edit") }}{% end block %}
+
+{% block container %}
+ {% import pakfire %}
+
+ <nav class="breadcrumb" aria-label="breadcrumbs">
+ <ul>
+ <li>
+ <a href="/distros">{{ _("Distributions") }}</a>
+ </li>
+ <li>
+ <a href="/distros/{{ distro.slug }}">{{ distro }}</a>
+ </li>
+ <li class="is-active">
+ <a href="#" aria-current="page">{{ _("Edit") }}</a>
+ </li>
+ </ul>
+ </nav>
+
+ <div class="columns is-centered">
+ <div class="column is-6">
+ <form method="POST" action="">
+ <div class="box">
+ {% raw xsrf_form_html() %}
+
+ {# Name #}
+ <div class="field">
+ <label class="label">{{ _("Name") }}</label>
+ <div class="control">
+ <input class="input" type="text"
+ name="name" value="{{ distro.name }}" required>
+ </div>
+ <p class="help">
+ {{ _("The name of this distributions") }}
+ </p>
+ </div>
+
+ <fieldset>
+ {# Vendor #}
+ <div class="field">
+ <label class="label">{{ _("Vendor") }}</label>
+ <div class="control">
+ <input class="input" type="text"
+ name="vendor" value="{{ distro.vendor }}">
+ </div>
+ <p class="help">
+ {{ _("The vendor of this distributions") }}
+ </p>
+ </div>
+
+ {# Contact #}
+ <div class="field">
+ <label class="label">{{ _("Contact") }}</label>
+ <div class="control">
+ <input class="input" type="text"
+ name="contact" value="{{ distro.contact }}">
+ </div>
+ <p class="help">
+ {{ _("The contact of this distributions") }}
+ </p>
+ </div>
+
+ {# Slogan #}
+ <div class="field">
+ <label class="label">{{ _("Slogan") }}</label>
+ <div class="control">
+ <input class="input" type="text"
+ name="slogan" value="{{ distro.slogan }}">
+ </div>
+ <p class="help">
+ {{ _("The slogan of this distributions") }}
+ </p>
+ </div>
+ </fieldset>
+
+ <div class="field">
+ <label class="label">{{ _("Architectures") }}</label>
+
+ <div class="control">
+ <div class="select is-multiple">
+ <select multiple name="arches">
+ {% for arch in pakfire.supported_arches() %}
+ <option value="{{ arch }}"
+ {% if arch in distro.arches %}selected{% end %}>{{ arch }}</option>
+ {% end %}
+ </select>
+ </div>
+ </div>
+ </div>
+
+ <div class="field is-grouped">
+ <div class="control">
+ <button class="button is-success is-link" type="submit">
+ {{ _("Save") }}
+ </button>
+ </div>
+
+ <div class="control">
+ <a class="button is-danger is-outlined is-link" href="/distros/{{ distro.slug }}/delete">
+ {{ _("Delete") }}
+ </a>
+ </div>
+ </div>
+ </div>
+ </form>
+ </div>
+ </div>
+{% end block %}
</div>
</div>
</nav>
+
+ <div class="buttons are-small">
+ {% if distro.has_perm(current_user) %}
+ <a class="button is-warning" href="/distros/{{ distro.slug }}/edit">
+ {{ _("Edit") }}
+ </a>
+ {% end %}
+ </div>
</div>
</div>
{% end %}
# Distributions
(r"/distros", distributions.IndexHandler),
(r"/distros/([A-Za-z0-9\-\.]+)", distributions.ShowHandler),
+ (r"/distros/([A-Za-z0-9\-\.]+)/edit", distributions.EditHandler),
(r"/distros/(?P<distro_slug>[A-Za-z0-9\-\.]+)/repos/(?P<repo_slug>[A-Za-z0-9\-]+)",
repos.ShowHandler),
(r"/distros/(?P<distro_slug>[A-Za-z0-9\-\.]+)/repos/(?P<repo_slug>[A-Za-z0-9\-]+)\.repo",
self.render("distros/show.html", distro=distro)
-class DistributionEditHandler(base.BaseHandler):
- def prepare(self):
- self.sources = self.backend.sources.get_all()
-
+class EditHandler(base.BaseHandler):
@tornado.web.authenticated
- def get(self, name):
- distro = self.backend.distros.get_by_slug(name)
+ def get(self, slug):
+ distro = self.backend.distros.get_by_slug(slug)
if not distro:
- raise tornado.web.HTTPError(404, "Distro not found")
+ raise tornado.web.HTTPError(404, "Could not find distribution: %s" % slug)
+
+ # Check for permissions
+ if not distro.has_perm(self.current_user):
+ raise tornado.web.HTTPError(403)
- self.render("distro-edit.html", distro=distro, sources=self.sources)
+ self.render("distros/edit.html", distro=distro)
@tornado.web.authenticated
- def post(self, name):
- distro = self.backend.distros.get_by_slug(name)
+ def post(self, slug):
+ distro = self.backend.distros.get_by_slug(slug)
if not distro:
- raise tornado.web.HTTPError(404, "Distro not found")
-
- name = self.get_argument("name", distro.name)
- vendor = self.get_argument("vendor", distro.vendor)
- contact = self.get_argument("contact", "")
- slogan = self.get_argument("slogan", distro.slogan)
- tag = self.get_argument("tag", "")
-
- distro.set("name", name)
- distro.set("vendor", vendor)
- distro.set("slogan", slogan)
-
- # Update the contact email address.
- distro.contact = contact
-
- # Update the tag.
- distro.tag = tag
+ raise tornado.web.HTTPError(404, "Could not find distribution: %s" % slug)
- # Update architectures
- distro.arches = self.get_arguments("arches", [])
+ with self.db.transaction():
+ distro.name = self.get_argument("name")
+ distro.vendor = self.get_argument("vendor", None)
+ distro.contact = self.get_argument("contact", None)
+ distro.slogan = self.get_argument("slogan", None)
+ distro.arches = self.get_arguments("arches")
- self.redirect("/distribution/%s" % distro.slug)
+ self.redirect("/distros/%s" % distro.slug)
class DistroSourceDetailHandler(base.BaseHandler):