Added the user details in the Mia core application.

This commit is contained in:
2020-08-09 20:47:53 +08:00
parent 229ce011b5
commit c500f15945
4 changed files with 296 additions and 15 deletions

View File

@ -0,0 +1,171 @@
{% extends "base.html" %}
{% comment %}
The Mia Core Application
user_detail.html: The template for the user details
Copyright (c) 2020 imacat.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: imacat@mail.imacat.idv.tw (imacat)
First written: 2020/8/9
{% endcomment %}
{% load i18n %}
{% load mia_core %}
{% block settings %}
{% setvar "title" user.name %}
{% endblock %}
{% block content %}
{% if not user.is_in_use %}
<div class="alert alert-info alert-dismissible fade show">
<button type="button" class="close" data-dismiss="alert">&times;</button>
{{ _("The account is not in use.")|force_escape }}
</div>
{% endif %}
<!-- the delete confirmation dialog -->
<form action="{% url "mia_core:users.delete" user %}" method="POST">
{% csrf_token %}
<!-- The Modal -->
<div class="modal" id="del-modal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">{{ _("User Deletion Confirmation")|force_escape }}</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body">{{ _("Do you really want to delete this user?")|force_escape }}</div>
<!-- Modal footer -->
<div class="modal-footer">
<button class="btn btn-danger" type="submit" name="del-confirm">{{ _("Confirm")|force_escape }}</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ _("Cancel")|force_escape }}</button>
</div>
</div>
</div>
</div>
</form>
<div class="btn-group btn-actions">
<a class="btn btn-primary" role="button" href="{% url "mia_core:users" %}">
<i class="fas fa-chevron-circle-left"></i>
{{ _("Back")|force_escape }}
</a>
<a class="btn btn-primary" role="button" href="{% url "mia_core:users.edit" user %}">
<i class="fas fa-user-cog"></i>
{{ _("Setting")|force_escape }}
</a>
{% if user.login_id == request.user.login_id %}
<button class="btn btn-secondary" type="button" disabled="disabled" title="{{ _("You cannot delete your own account.")|force_escape }}">
<i class="fas fa-trash"></i>
{{ _("Delete")|force_escape }}
</button>
{% elif user.is_in_use %}
<button class="btn btn-secondary" type="button" disabled="disabled" title="{{ _("You cannot delete this account because it is in use.")|force_escape }}">
<i class="fas fa-trash"></i>
{{ _("Delete")|force_escape }}
</button>
{% elif user.is_deleted %}
<button class="btn btn-secondary" type="button" disabled="disabled" title="{{ _("This account is already deleted.")|force_escape }}>">
<i class="fas fa-trash"></i>
{{ _("Delete")|force_escape }}
</button>
{% else %}
<button class="btn btn-danger" type="button" data-toggle="modal" data-target="#del-modal">
<i class="fas fa-trash"></i>
{{ _("Delete")|force_escape }}
</button>
{% endif %}
</div>
<div class="row form-group">
<div class="col-sm-2">{{ _("Login ID.:")|force_escape }}</div>
<div class="col-sm-10">{{ user.login_id }}</div>
</div>
<div class="row form-group">
<div class="col-sm-2">{{ _("Name:")|force_escape }}</div>
<div class="col-sm-10">{{ user.name }}</div>
</div>
{% if user.is_disabled %}
<div class="row form-group">
<div class="col-sm-12">{{ _("This account is disabled.")|force_escape }}</div>
</div>
{% endif %}
{% if user.is_deleted %}
<div class="row form-group">
<div class="col-sm-12">{{ _("This account is deleted.")|force_escape }}</div>
</div>
{% endif %}
{% if not user.visits %}
<div class="row form-group">
<div class="col-sm-12">{{ _("This user has not logged in yet.")|force_escape }}</div>
</div>
{% else %}
<div class="row form-group">
<div class="col-sm-2">{{ _("# of visits:")|force_escape }}</div>
<div class="col-sm-10">{{ user.visits }}</div>
</div>
<div class="row form-group">
<div class="col-sm-2">{{ _("Last visit at:")|force_escape }}</div>
<div class="col-sm-10">{{ user.visited_at }}</div>
</div>
<div class="row form-group">
<div class="col-sm-2">{{ _("IP:")|force_escape }}</div>
<div class="col-sm-10">{{ user.visited_ip }}</div>
</div>
<div class="row form-group">
<div class="col-sm-2">{{ _("Host:")|force_escape }}</div>
<div class="col-sm-10">{{ user.visited_host }}</div>
</div>
<div class="row form-group">
<div class="col-sm-2">{{ _("Country:")|force_escape }}</div>
<div class="col-sm-10">{{ user.visited_country.name|default:_("(Not Available)")|force_escape }}</div>
</div>
{% endif %}
<div class="row form-group">
<div class="col-sm-2">{{ _("Created at:")|force_escape }}</div>
<div class="col-sm-10">{{ account.created_at }}</div>
</div>
<div class="row form-group">
<div class="col-sm-2">{{ _("Created by:")|force_escape }}</div>
<div class="col-sm-10">{{ account.created_by }}</div>
</div>
<div class="row form-group">
<div class="col-sm-2">{{ _("Updated at:")|force_escape }}</div>
<div class="col-sm-10">{{ account.updated_at }}</div>
</div>
<div class="row form-group">
<div class="col-sm-2">{{ _("Updated by:")|force_escape }}</div>
<div class="col-sm-10">{{ account.updated_by }}</div>
</div>
{% endblock %}