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)
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
);
</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>
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)