Add admin profile page
parent
4f1b51f7d5
commit
ba1d3657b9
47
app/admin.py
47
app/admin.py
|
@ -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")
|
@router.post("/actions/follow")
|
||||||
def admin_actions_follow(
|
def admin_actions_follow(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
|
@ -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 %}
|
|
@ -59,6 +59,13 @@
|
||||||
</form>
|
</form>
|
||||||
{% endmacro %}
|
{% 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) %}
|
{% macro display_actor(actor, actors_metadata) %}
|
||||||
{% set metadata = actors_metadata.get(actor.ap_id) %}
|
{% set metadata = actors_metadata.get(actor.ap_id) %}
|
||||||
<div style="display: flex;column-gap: 20px;margin:20px 0 10px 0;" class="actor-box">
|
<div style="display: flex;column-gap: 20px;margin:20px 0 10px 0;" class="actor-box">
|
||||||
|
@ -194,6 +201,9 @@
|
||||||
<div class="bar-item">
|
<div class="bar-item">
|
||||||
{{ admin_reply_button(object.ap_id) }}
|
{{ admin_reply_button(object.ap_id) }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="bar-item">
|
||||||
|
{{ admin_profile_button(object.actor.ap_id) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue