Add admin profile page

main
Thomas Sileo 2022-06-25 12:19:12 +02:00
parent 4f1b51f7d5
commit ba1d3657b9
3 changed files with 65 additions and 0 deletions

View File

@ -223,6 +223,53 @@ def get_notifications(
)
@router.get("/object")
def admin_object(
request: Request,
ap_id: str,
db: Session = Depends(get_db),
) -> templates.TemplateResponse:
return templates.render_template(
db,
request,
"admin_object.html",
{},
)
@router.get("/profile")
def admin_profile(
request: Request,
actor_id: str,
db: Session = Depends(get_db),
) -> templates.TemplateResponse:
actor = db.query(models.Actor).filter(models.Actor.ap_id == actor_id).one_or_none()
if not actor:
raise HTTPException(status_code=404)
actors_metadata = get_actors_metadata(db, [actor])
inbox_objects = (
db.query(models.InboxObject)
.filter(
models.InboxObject.actor_id == actor.id,
models.InboxObject.ap_type.in_(["Note", "Article", "Video"]),
)
.all()
)
return templates.render_template(
db,
request,
"admin_profile.html",
{
"actors_metadata": actors_metadata,
"actor": actor,
"inbox_objects": inbox_objects,
},
)
@router.post("/actions/follow")
def admin_actions_follow(
request: Request,

View File

@ -0,0 +1,8 @@
{%- import "utils.html" as utils with context -%}
{% extends "layout.html" %}
{% block content %}
{{ utils.display_actor(actor, actors_metadata) }}
{% for inbox_object in inbox_objects %}
{{ utils.display_object(inbox_object) }}
{% endfor %}
{% endblock %}

View File

@ -59,6 +59,13 @@
</form>
{% endmacro %}
{% macro admin_profile_button(ap_actor_id) %}
<form action="{{ url_for("admin_profile") }}" method="GET">
<input type="hidden" name="actor_id" value="{{ ap_actor_id }}">
<button type="submit">Profile</button>
</form>
{% endmacro %}
{% macro display_actor(actor, actors_metadata) %}
{% set metadata = actors_metadata.get(actor.ap_id) %}
<div style="display: flex;column-gap: 20px;margin:20px 0 10px 0;" class="actor-box">
@ -194,6 +201,9 @@
<div class="bar-item">
{{ admin_reply_button(object.ap_id) }}
</div>
<div class="bar-item">
{{ admin_profile_button(object.actor.ap_id) }}
</div>
{% endif %}