mirror of https://git.sr.ht/~sircmpwn/man.sr.ht
Add option to set wiki visibility on creation flow
This commit is contained in:
parent
02f8e1c013
commit
77a1423ffa
|
@ -58,12 +58,14 @@ def create_POST():
|
|||
wiki_name = valid.require("name", friendly_name="Name")
|
||||
if not valid.ok:
|
||||
return render_template("create.html", **valid.kwargs)
|
||||
|
||||
validate_name(valid, current_user, wiki_name)
|
||||
if not valid.ok:
|
||||
return render_template("create.html", **valid.kwargs)
|
||||
|
||||
visibility = valid.optional("visibility",
|
||||
default="public",
|
||||
cls=WikiVisibility)
|
||||
session["wiki_name"] = wiki_name
|
||||
session["wiki_visibility"] = visibility.name
|
||||
return redirect("/wiki/create/repo")
|
||||
|
||||
@create.route("/wiki/create/repo")
|
||||
|
@ -115,6 +117,7 @@ def select_ref_POST():
|
|||
return redirect("/wiki/create")
|
||||
|
||||
is_root = session.get("configure_root", False)
|
||||
visibility = WikiVisibility(session.get("wiki_visibility", "public"))
|
||||
repo_name, new_repo = wiki_repo
|
||||
backend = GitsrhtBackend(current_user)
|
||||
|
||||
|
@ -145,10 +148,13 @@ def select_ref_POST():
|
|||
repo = create_repo(
|
||||
new_repo, repo_name, ref_name,
|
||||
hook["id"], commit=commit)
|
||||
create_wiki(valid, current_user, wiki_name, repo, is_root=is_root)
|
||||
create_wiki(
|
||||
valid, current_user, wiki_name,
|
||||
repo, visibility, is_root=is_root)
|
||||
|
||||
del session["wiki_name"]
|
||||
del session["wiki_repo"]
|
||||
session.pop("wiki_visibility", None)
|
||||
session.pop("configure_root", None)
|
||||
|
||||
return redirect("/{}/{}".format(current_user.canonical_name, wiki_name))
|
||||
|
|
|
@ -23,6 +23,48 @@
|
|||
value="{{ repo_name or "" }}" />
|
||||
{{valid.summary("name")}}
|
||||
</div>
|
||||
{% if not is_root %}
|
||||
<fieldset class="form-group">
|
||||
<legend>Visibility</legend>
|
||||
<div class="form-check form-check-inline">
|
||||
<label
|
||||
class="form-check-label"
|
||||
title="Publically visible and listed on your profile"
|
||||
>
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="visibility"
|
||||
value="public"
|
||||
checked> Public
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<label
|
||||
class="form-check-label"
|
||||
title="Visible to anyone with the link, but not shown on your profile"
|
||||
>
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="visibility"
|
||||
value="unlisted"> Unlisted
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<label
|
||||
class="form-check-label"
|
||||
title="Only visible to you and your collaborators"
|
||||
>
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="visibility"
|
||||
value="private"> Private
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Select repo {{icon("caret-right")}}
|
||||
</button>
|
||||
|
|
|
@ -47,12 +47,12 @@ def create_repo(is_new, name, ref, webhook_id, commit=None):
|
|||
db.session.commit()
|
||||
return repo
|
||||
|
||||
|
||||
def create_wiki(valid, owner, wiki_name, repo, is_root=False):
|
||||
def create_wiki(valid, owner, wiki_name, repo, visibility, is_root=False):
|
||||
wiki = Wiki()
|
||||
wiki.name = wiki_name
|
||||
wiki.owner_id = owner.id
|
||||
wiki.repo_id = repo.id
|
||||
wiki.visibility = visibility
|
||||
db.session.add(wiki)
|
||||
db.session.flush()
|
||||
|
||||
|
|
Loading…
Reference in New Issue