]> git.ipfire.org Git - pbs.git/commitdiff
mirrors: Add option to support HTTPS
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Oct 2017 11:42:23 +0000 (12:42 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Oct 2017 11:42:23 +0000 (12:42 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/mirrors.py
src/database.sql
src/templates/mirrors-edit.html
src/web/handlers_mirrors.py

index 61404f7c79292dcf1a2e006b08406d231667c872..0c28ddd4dcd1ed881ed1f4c6a315b8c37e1832e6 100644 (file)
@@ -160,13 +160,22 @@ class Mirror(base.DataObject):
                return self.make_url()
 
        def make_url(self, path=""):
-               url = "http://%s%s" % (self.hostname, self.path)
+               url = "%s://%s%s" % (
+                       "https" if self.supports_https else "http",
+                       self.hostname,
+                       self.path
+               )
 
                if path.startswith("/"):
                        path = path[1:]
 
                return urlparse.urljoin(url, path)
 
+       def set_supports_https(self, supports_https):
+               self._set_attribute("supports_https", supports_https)
+
+       supports_https = property(lambda s: s.data.supports_https, set_supports_https)
+
        def set_owner(self, owner):
                self._set_attribute("owner", owner)
 
index 96a03d424ca926344c70cf23e5a3317b82264fda..01a133106a42b7ef35a7fd12e3471d49c41f2d34 100644 (file)
@@ -1291,7 +1291,8 @@ CREATE TABLE mirrors (
     path text NOT NULL,
     owner text,
     contact text,
-    deleted boolean DEFAULT false NOT NULL
+    deleted boolean DEFAULT false NOT NULL,
+    supports_https boolean DEFAULT false NOT NULL
 );
 
 
index ab6c7f482e9534dbad0bf249ad5f0aad6848c0f9..2e3b3c3ff9b63da8a3c0895a87c14fa1d5d64c1a 100644 (file)
                        </div>
 
                        <div class="control-group">
-                               <label class="control-label" for="enabled">{{ _("Enabled") }}</label>
+                               <label class="control-label">{{ _("Supports HTTPS") }}</label>
                                <div class="controls">
                                        <label class="checkbox">
-                                               <input type="checkbox" id="enabled" name="enabled" {% if mirror.enabled %}checked="checked"{% end %}>
-                                               {{ _("Only enabled mirrors will be pushed out to the clients.") }}
+                                               <input type="checkbox" name="supports_https" {% if mirror.supports_https %}checked{% end %}>
+                                               {{ _("Check if this mirror server supports HTTPS.") }}
                                        </label>
                                </div>
                        </div>
index 42d986a3deebc88287e6413aa09e2f8bcac0c42e..fa32e43a63e1038c44761317d46d4bfce8bcb9fa 100644 (file)
@@ -99,21 +99,12 @@ class MirrorEditHandler(MirrorActionHandler):
                if not mirror:
                        raise tornado.web.HTTPError(404, "Could not find mirror: %s" % hostname)
 
-               hostname = self.get_argument("name")
-               path     = self.get_argument("path", "")
-               owner    = self.get_argument("owner", None)
-               contact  = self.get_argument("contact", None)
-               enabled  = self.get_argument("enabled", None)
-
-               if enabled:
-                       mirror.set_status("enabled", user=self.current_user)
-               else:
-                       mirror.set_status("disabled", user=self.current_user)
-
-               mirror.hostname = hostname
-               mirror.path     = path
-               mirror.owner    = owner
-               mirror.contact  = contact
+               with self.db.transaction():
+                       mirror.hostname       = self.get_argument("name")
+                       mirror.path           = self.get_argument("path", "")
+                       mirror.owner          = self.get_argument("owner", None)
+                       mirror.contact        = self.get_argument("contact", None)
+                       mirror.supports_https = self.get_argument("supports_https", False)
 
                self.redirect("/mirror/%s" % mirror.hostname)