mirror of https://git.sr.ht/~sircmpwn/hub.sr.ht
Add search & manage page for mailing lists
This commit is contained in:
parent
1ba020a264
commit
b6b673e4d7
|
@ -225,9 +225,20 @@ def mailing_lists_GET(owner, project_name):
|
|||
mailing_lists = (MailingList.query
|
||||
.filter(MailingList.project_id == project.id)
|
||||
.order_by(MailingList.updated.desc()))
|
||||
|
||||
terms = request.args.get("search")
|
||||
search_error = None
|
||||
try:
|
||||
mailing_lists = search_by(mailing_lists, terms,
|
||||
[MailingList.name, MailingList.description])
|
||||
except ValueError as ex:
|
||||
search_error = str(ex)
|
||||
|
||||
mailing_lists, pagination = paginate_query(mailing_lists)
|
||||
return render_template("project-mailing-lists.html", view="mailing lists",
|
||||
owner=owner, project=project, mailing_lists=mailing_lists,
|
||||
owner=owner, project=project,
|
||||
search=terms, search_error=search_error,
|
||||
mailing_lists=mailing_lists,
|
||||
**pagination)
|
||||
|
||||
@projects.route("/<owner>/<project_name>/lists/new")
|
||||
|
@ -294,3 +305,26 @@ def mailing_lists_new_POST(owner, project_name):
|
|||
|
||||
return redirect(url_for("projects.summary_GET",
|
||||
owner=owner.canonical_name, project_name=project.name))
|
||||
|
||||
@projects.route("/<owner>/<project_name>/lists/manage")
|
||||
@loginrequired
|
||||
def mailing_lists_manage_GET(owner, project_name):
|
||||
owner, project = get_project(owner, project_name, ProjectAccess.write)
|
||||
mailing_lists = (MailingList.query
|
||||
.filter(MailingList.project_id == project.id)
|
||||
.order_by(MailingList.updated.desc()))
|
||||
|
||||
terms = request.args.get("search")
|
||||
search_error = None
|
||||
try:
|
||||
mailing_lists = search_by(mailing_lists, terms,
|
||||
[MailingList.name, MailingList.description])
|
||||
except ValueError as ex:
|
||||
search_error = str(ex)
|
||||
|
||||
mailing_lists, pagination = paginate_query(mailing_lists)
|
||||
return render_template("project-mailing-lists-manage.html",
|
||||
view="mailing lists", owner=owner, project=project,
|
||||
search=terms, search_error=search_error,
|
||||
mailing_lists=mailing_lists,
|
||||
**pagination)
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
<div class="header-tabbed">
|
||||
<div class="container">
|
||||
{% include 'project-nav.html' %}
|
||||
</div>
|
||||
</div>
|
||||
{% if project.description %}
|
||||
<div class="header-extension">
|
||||
<div class="container">
|
||||
{{ project.description }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 event-list">
|
||||
<h3>Manage mailing lists</h3>
|
||||
<form>
|
||||
<input
|
||||
name="search"
|
||||
type="text"
|
||||
placeholder="Search repositories"
|
||||
class="form-control{% if search_error %} is-invalid{% endif %}"
|
||||
value="{{ search if search else "" }}" />
|
||||
{% if search_error %}
|
||||
<div class="invalid-feedback">{{ search_error }}</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% for mailing_list in mailing_lists %}
|
||||
<div class="event">
|
||||
<h4>
|
||||
<a
|
||||
href="{{mailing_list.url()}}"
|
||||
>~{{owner.username}}/{{mailing_list.name}}</a>
|
||||
</h4>
|
||||
{% if mailing_list.description %}
|
||||
{{ mailing_list.description | md }}
|
||||
{% endif %}
|
||||
<form
|
||||
class="d-inline"
|
||||
method="POST"
|
||||
action="#TODO"
|
||||
>
|
||||
{{csrf_token()}}
|
||||
<button class="btn btn-danger">
|
||||
Remove mailing list {{icon('caret-right')}}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{{pagination()}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -12,7 +12,20 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="container">
|
||||
<form class="container">
|
||||
<div class="row">
|
||||
<div class="form-group col-md-12">
|
||||
<input
|
||||
name="search"
|
||||
type="text"
|
||||
placeholder="Search mailing lists"
|
||||
class="form-control{% if search_error %} is-invalid{% endif %}"
|
||||
value="{{ search if search else "" }}" />
|
||||
{% if search_error %}
|
||||
<div class="invalid-feedback">{{ search_error }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-10 event-list">
|
||||
{% for mailing_list in mailing_lists %}
|
||||
|
@ -36,8 +49,13 @@
|
|||
owner=owner.canonical_name, project_name=project.name)}}"
|
||||
class="btn btn-primary btn-block"
|
||||
>Add mailing list {{icon('caret-right')}}</a>
|
||||
<a
|
||||
href="{{url_for("projects.mailing_lists_manage_GET",
|
||||
owner=owner.canonical_name, project_name=project.name)}}"
|
||||
class="btn btn-default btn-block"
|
||||
>Manage lists {{icon('caret-right')}}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue