Commit c14eb421 authored by ibuler's avatar ibuler

reslove conflict add user detail template

parents 98d6043f 7a8d4a3a
/* The MIT License */
.dropzone,
.dropzone *,
.dropzone-previews,
.dropzone-previews * {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.dropzone {
position: relative;
border: 1px solid rgba(0,0,0,0.08);
background: rgba(0,0,0,0.02);
padding: 1em;
}
.dropzone.dz-clickable {
cursor: pointer;
}
.dropzone.dz-clickable .dz-message,
.dropzone.dz-clickable .dz-message span {
cursor: pointer;
}
.dropzone.dz-clickable * {
cursor: default;
}
.dropzone .dz-message {
opacity: 1;
-ms-filter: none;
filter: none;
}
.dropzone.dz-drag-hover {
border-color: rgba(0,0,0,0.15);
background: rgba(0,0,0,0.04);
}
.dropzone.dz-started .dz-message {
display: none;
}
.dropzone .dz-preview,
.dropzone-previews .dz-preview {
background: rgba(255,255,255,0.8);
position: relative;
display: inline-block;
margin: 17px;
vertical-align: top;
border: 1px solid #acacac;
padding: 6px 6px 6px 6px;
}
.dropzone .dz-preview.dz-file-preview [data-dz-thumbnail],
.dropzone-previews .dz-preview.dz-file-preview [data-dz-thumbnail] {
display: none;
}
.dropzone .dz-preview .dz-details,
.dropzone-previews .dz-preview .dz-details {
width: 100px;
height: 100px;
position: relative;
background: #ebebeb;
padding: 5px;
margin-bottom: 22px;
}
.dropzone .dz-preview .dz-details .dz-filename,
.dropzone-previews .dz-preview .dz-details .dz-filename {
overflow: hidden;
height: 100%;
}
.dropzone .dz-preview .dz-details img,
.dropzone-previews .dz-preview .dz-details img {
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
}
.dropzone .dz-preview .dz-details .dz-size,
.dropzone-previews .dz-preview .dz-details .dz-size {
position: absolute;
bottom: -28px;
left: 3px;
height: 28px;
line-height: 28px;
}
.dropzone .dz-preview.dz-error .dz-error-mark,
.dropzone-previews .dz-preview.dz-error .dz-error-mark {
display: block;
}
.dropzone .dz-preview.dz-success .dz-success-mark,
.dropzone-previews .dz-preview.dz-success .dz-success-mark {
display: block;
}
.dropzone .dz-preview:hover .dz-details img,
.dropzone-previews .dz-preview:hover .dz-details img {
display: none;
}
.dropzone .dz-preview .dz-success-mark,
.dropzone-previews .dz-preview .dz-success-mark,
.dropzone .dz-preview .dz-error-mark,
.dropzone-previews .dz-preview .dz-error-mark {
display: none;
position: absolute;
width: 40px;
height: 40px;
font-size: 30px;
text-align: center;
right: -10px;
top: -10px;
}
.dropzone .dz-preview .dz-success-mark,
.dropzone-previews .dz-preview .dz-success-mark {
color: #8cc657;
}
.dropzone .dz-preview .dz-error-mark,
.dropzone-previews .dz-preview .dz-error-mark {
color: #ee162d;
}
.dropzone .dz-preview .dz-progress,
.dropzone-previews .dz-preview .dz-progress {
position: absolute;
top: 100px;
left: 6px;
right: 6px;
height: 6px;
background: #d7d7d7;
display: none;
}
.dropzone .dz-preview .dz-progress .dz-upload,
.dropzone-previews .dz-preview .dz-progress .dz-upload {
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 0%;
background-color: #8cc657;
}
.dropzone .dz-preview.dz-processing .dz-progress,
.dropzone-previews .dz-preview.dz-processing .dz-progress {
display: block;
}
.dropzone .dz-preview .dz-error-message,
.dropzone-previews .dz-preview .dz-error-message {
display: none;
position: absolute;
top: -5px;
left: -20px;
background: rgba(245,245,245,0.8);
padding: 8px 10px;
color: #800;
min-width: 140px;
max-width: 500px;
z-index: 500;
}
.dropzone .dz-preview:hover.dz-error .dz-error-message,
.dropzone-previews .dz-preview:hover.dz-error .dz-error-message {
display: block;
}
This diff is collapsed.
/* Magnific Popup CSS */
.mfp-bg {
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1042;
overflow: hidden;
position: fixed;
background: #0b0b0b;
opacity: 0.8;
filter: alpha(opacity=80); }
.mfp-wrap {
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1043;
position: fixed;
outline: none !important;
-webkit-backface-visibility: hidden; }
.mfp-container {
text-align: center;
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
padding: 0 8px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box; }
.mfp-container:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle; }
.mfp-align-top .mfp-container:before {
display: none; }
.mfp-content {
position: relative;
display: inline-block;
vertical-align: middle;
margin: 0 auto;
text-align: left;
z-index: 1045; }
.mfp-inline-holder .mfp-content, .mfp-ajax-holder .mfp-content {
width: 100%;
cursor: auto; }
.mfp-ajax-cur {
cursor: progress; }
.mfp-zoom-out-cur, .mfp-zoom-out-cur .mfp-image-holder .mfp-close {
cursor: -moz-zoom-out;
cursor: -webkit-zoom-out;
cursor: zoom-out; }
.mfp-zoom {
cursor: pointer;
cursor: -webkit-zoom-in;
cursor: -moz-zoom-in;
cursor: zoom-in; }
.mfp-auto-cursor .mfp-content {
cursor: auto; }
.mfp-close, .mfp-arrow, .mfp-preloader, .mfp-counter {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none; }
.mfp-loading.mfp-figure {
display: none; }
.mfp-hide {
display: none !important; }
.mfp-preloader {
color: #CCC;
position: absolute;
top: 50%;
width: auto;
text-align: center;
margin-top: -0.8em;
left: 8px;
right: 8px;
z-index: 1044; }
.mfp-preloader a {
color: #CCC; }
.mfp-preloader a:hover {
color: #FFF; }
.mfp-s-ready .mfp-preloader {
display: none; }
.mfp-s-error .mfp-content {
display: none; }
button.mfp-close, button.mfp-arrow {
overflow: visible;
cursor: pointer;
background: transparent;
border: 0;
-webkit-appearance: none;
display: block;
outline: none;
padding: 0;
z-index: 1046;
-webkit-box-shadow: none;
box-shadow: none; }
button::-moz-focus-inner {
padding: 0;
border: 0; }
.mfp-close {
width: 44px;
height: 44px;
line-height: 44px;
position: absolute;
right: 0;
top: 0;
text-decoration: none;
text-align: center;
opacity: 0.65;
filter: alpha(opacity=65);
padding: 0 0 18px 10px;
color: #FFF;
font-style: normal;
font-size: 28px;
font-family: Arial, Baskerville, monospace; }
.mfp-close:hover, .mfp-close:focus {
opacity: 1;
filter: alpha(opacity=100); }
.mfp-close:active {
top: 1px; }
.mfp-close-btn-in .mfp-close {
color: #333; }
.mfp-image-holder .mfp-close, .mfp-iframe-holder .mfp-close {
color: #FFF;
right: -6px;
text-align: right;
padding-right: 6px;
width: 100%; }
.mfp-counter {
position: absolute;
top: 0;
right: 0;
color: #CCC;
font-size: 12px;
line-height: 18px;
white-space: nowrap; }
.mfp-arrow {
position: absolute;
opacity: 0.65;
filter: alpha(opacity=65);
margin: 0;
top: 50%;
margin-top: -55px;
padding: 0;
width: 90px;
height: 110px;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
.mfp-arrow:active {
margin-top: -54px; }
.mfp-arrow:hover, .mfp-arrow:focus {
opacity: 1;
filter: alpha(opacity=100); }
.mfp-arrow:before, .mfp-arrow:after, .mfp-arrow .mfp-b, .mfp-arrow .mfp-a {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: 0;
top: 0;
margin-top: 35px;
margin-left: 35px;
border: medium inset transparent; }
.mfp-arrow:after, .mfp-arrow .mfp-a {
border-top-width: 13px;
border-bottom-width: 13px;
top: 8px; }
.mfp-arrow:before, .mfp-arrow .mfp-b {
border-top-width: 21px;
border-bottom-width: 21px;
opacity: 0.7; }
.mfp-arrow-left {
left: 0; }
.mfp-arrow-left:after, .mfp-arrow-left .mfp-a {
border-right: 17px solid #FFF;
margin-left: 31px; }
.mfp-arrow-left:before, .mfp-arrow-left .mfp-b {
margin-left: 25px;
border-right: 27px solid #3F3F3F; }
.mfp-arrow-right {
right: 0; }
.mfp-arrow-right:after, .mfp-arrow-right .mfp-a {
border-left: 17px solid #FFF;
margin-left: 39px; }
.mfp-arrow-right:before, .mfp-arrow-right .mfp-b {
border-left: 27px solid #3F3F3F; }
.mfp-iframe-holder {
padding-top: 40px;
padding-bottom: 40px; }
.mfp-iframe-holder .mfp-content {
line-height: 0;
width: 100%;
max-width: 900px; }
.mfp-iframe-holder .mfp-close {
top: -40px; }
.mfp-iframe-scaler {
width: 100%;
height: 0;
overflow: hidden;
padding-top: 56.25%; }
.mfp-iframe-scaler iframe {
position: absolute;
display: block;
top: 0;
left: 0;
width: 100%;
height: 100%;
box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
background: #000; }
/* Main image in popup */
img.mfp-img {
width: auto;
max-width: 100%;
height: auto;
display: block;
line-height: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 40px 0 40px;
margin: 0 auto; }
/* The shadow behind the image */
.mfp-figure {
line-height: 0; }
.mfp-figure:after {
content: '';
position: absolute;
left: 0;
top: 40px;
bottom: 40px;
display: block;
right: 0;
width: auto;
height: auto;
z-index: -1;
box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
background: #444; }
.mfp-figure small {
color: #BDBDBD;
display: block;
font-size: 12px;
line-height: 14px; }
.mfp-figure figure {
margin: 0; }
.mfp-bottom-bar {
margin-top: -36px;
position: absolute;
top: 100%;
left: 0;
width: 100%;
cursor: auto; }
.mfp-title {
text-align: left;
line-height: 18px;
color: #F3F3F3;
word-wrap: break-word;
padding-right: 36px; }
.mfp-image-holder .mfp-content {
max-width: 100%; }
.mfp-gallery .mfp-image-holder .mfp-figure {
cursor: pointer; }
@media screen and (max-width: 800px) and (orientation: landscape), screen and (max-height: 300px) {
/**
* Remove all paddings around the image on small screen
*/
.mfp-img-mobile .mfp-image-holder {
padding-left: 0;
padding-right: 0; }
.mfp-img-mobile img.mfp-img {
padding: 0; }
.mfp-img-mobile .mfp-figure:after {
top: 0;
bottom: 0; }
.mfp-img-mobile .mfp-figure small {
display: inline;
margin-left: 5px; }
.mfp-img-mobile .mfp-bottom-bar {
background: rgba(0, 0, 0, 0.6);
bottom: 0;
margin: 0;
top: auto;
padding: 3px 5px;
position: fixed;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box; }
.mfp-img-mobile .mfp-bottom-bar:empty {
padding: 0; }
.mfp-img-mobile .mfp-counter {
right: 5px;
top: 3px; }
.mfp-img-mobile .mfp-close {
top: 0;
right: 0;
width: 35px;
height: 35px;
line-height: 35px;
background: rgba(0, 0, 0, 0.6);
position: fixed;
text-align: center;
padding: 0; }
}
@media all and (max-width: 900px) {
.mfp-arrow {
-webkit-transform: scale(0.75);
transform: scale(0.75); }
.mfp-arrow-left {
-webkit-transform-origin: 0;
transform-origin: 0; }
.mfp-arrow-right {
-webkit-transform-origin: 100%;
transform-origin: 100%; }
.mfp-container {
padding-left: 6px;
padding-right: 6px; }
}
.mfp-ie7 .mfp-img {
padding: 0; }
.mfp-ie7 .mfp-bottom-bar {
width: 600px;
left: 50%;
margin-left: -300px;
margin-top: 5px;
padding-bottom: 5px; }
.mfp-ie7 .mfp-container {
padding: 0; }
.mfp-ie7 .mfp-content {
padding-top: 44px; }
.mfp-ie7 .mfp-close {
top: 0;
right: 0;
padding-top: 0; }
This diff is collapsed.
......@@ -34,9 +34,9 @@ $(document).ready(function () {
});
// Append config box / Only for demo purpose
$.get("/skin_config/", function (data) {
$('body').append(data);
});
//$.get("/skin_config/", function (data) {
// $('body').append(data);
//});
// minimalize menu
$('.navbar-minimalize').click(function () {
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
{#<link href="{% static "css/animate.css" %}" rel="stylesheet">#}
<link href="{% static "css/style.css" %}" rel="stylesheet">
{#<link href="{% static "css/colorbox.css" %}" rel="stylesheet">#}
<link href="{% static "css/vaildator/jquery.validator.css" %}" rel="stylesheet">
<link href="{% static "css/plugins/vaildator/jquery.validator.css" %}" rel="stylesheet">
{#<link href="{% static "css/magnific/magnific-popup.css" %}" rel="stylesheet">#}
{#<link href="{% static "css/plugins/fullcalendar/fullcalendar.css" %}" rel="stylesheet">#}
{#<link href="{% static "css/dropzone/basic.css" %}" rel="stylesheet">#}
......
# ~*~ coding: utf-8 ~*~
from django.forms import ModelForm
from django import forms
from .models import User, UserGroup
......@@ -9,6 +10,11 @@ class UserForm(ModelForm):
class Meta:
model = User
fields = [
'username', 'password', 'name', 'email', 'groups', 'wechat',
'username', 'name', 'email', 'groups', 'wechat',
'phone', 'enable_2FA', 'role', 'date_expired', 'comment',
]
# widgets = {
# 'groups': forms.SelectMultiple(attrs={'class': 'chosen-select'})
# }
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-16 05:58
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0004_auto_20160815_2257'),
]
operations = [
migrations.AlterField(
model_name='user',
name='comment',
field=models.TextField(blank=True, max_length=200, verbose_name='\u63cf\u8ff0'),
),
]
{% extends 'base.html' %}
{% load static %}
{% load bootstrap %}
{% block custom_head_css_js %}
<link href="{% static "css/plugins/chosen/chosen.css" %}" rel="stylesheet">
<script href="{% static "js/plugins/chosen/chosen.jquery.min.js" %}" type="text/javascript"></script>
{% endblock %}
{% block content %}
<div class="wrapper wrapper-content animated fadeInRight">
......@@ -24,7 +29,7 @@
<form method="post" id="userForm" class="form-horizontal" action="">
{% csrf_token %}
<h3>账户</h3>
{{ form.username|bootstrap_horizontal }}
{% block username %} {% endblock %}
{{ form.name|bootstrap_horizontal }}
{{ form.email|bootstrap_horizontal }}
{{ form.groups|bootstrap_horizontal }}
......@@ -61,49 +66,19 @@
</div>
</div>
{% endblock %}
{% block self_footer_js %}
<script>
$('#userForm').validator({
timely: 2,
theme: "yellow_right_effect",
rules: {
check_username: [/^[\w.]{3,20}$/, '大小写字母数字和下划线小数点'],
type_m: function(element){
return $("#M").is(":checked");
}
},
fields: {
"username": {
rule: "required;check_username",
tip: "输入用户名",
ok: "",
msg: {required: "必须填写!"}
},
"password": {
rule: "required;length[6~50]",
tip: "输入密码",
ok: "",
msg: {required: "必须填写!"}
},
"name": {
rule: "required",
tip: "姓名",
ok: "",
msg: {required: "必须填写"}
},
"email": {
rule: "required",
tip: "Email",
ok: "",
msg: {required: "必须填写"}
}
},
valid: function(form) {
form.submit();
}
});
{% block custom_footer_js %}
<script type="text/javascript">
{#$(document).ready(function() {#}
{# var config = {#}
{# '.chosen-select': {},#}
{# '.chosen-select-deselect': {allow_single_deselect: true},#}
{# '.chosen-select-no-single': {disable_search_threshold: 10},#}
{# '.chosen-select-no-results': {no_results_text: 'Oops, nothing found!'},#}
{# '.chosen-select-width': {width: "95%"}#}
{# };#}
{# for (var selector in config) {#}
{# $(selector).chosen(config[selector]);#}
{# }#}
{#})#}
</script>
{% endblock %}
\ No newline at end of file
{% extends 'users/_user.html' %}
{% load bootstrap %}
{% block username %}
{{ form.username|bootstrap_horizontal }}
{% endblock %}
{% block password %}
<h3>密码</h3>
<div class="form-group">
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>确认删除</title>
</head>
<body>
<form action="" method="post">
{% csrf_token %}
<p>Are you sure you want to delete "{{ object.name }}"?</p>
<input type="submit" value="Confirm" />
</form>
</body>
</html>
\ No newline at end of file
{% extends 'base.html' %}
{% load common_tags %}
{% load static %}
{% block content %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
{# <div class="ibox-content">#}
<div class="panel-options">
<ul class="nav nav-tabs">
<li class="active"><a href="" class="text-center"><i class="fa fa-laptop"></i> 用户信息 </a></li>
<li><a href="" class="text-center"><i class="fa fa-bar-chart-o"></i> 用户资产</a></li>
<li><a href="" class="text-center"><i class="fa fa-bar-chart-o"></i> 登录记录 </a></li>
<div class="" style="float: right">
<form id="search_form" method="get" action="" class="pull-right mail-search">
<div class="input-group">
<input type="text" class="form-control input-sm" id="keyword" name="keyword" value="{{ keyword }}" placeholder="Search">
<div class="input-group-btn">
<button id='search_btn' type="submit" class="btn btn-sm btn-primary">
搜索
</button>
</div>
</div>
</form>
</div>
</ul>
</div>
<div class="tab-content">
<div class="col-sm-7" style="padding-left: 0px;">
<div class="ibox float-e-margins">
<div class="ibox-title">
<span class="label"><b>{{ user.name }}</b></span>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li><a href="#"></a>
</li>
<li><a href="#"></a>
</li>
</ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<table class="table">
<tbody>
<tr>
<td colspan="2">
<img src="{% static "img/root.png" %}" class="img-circle", width="64" height="64">
</td>
</tr>
<tr>
<td width="20%"><b>姓名:</b></td>
<td>{{ user.name }}</td>
</tr>
<tr>
<td><b>用户名:</b></td>
<td>{{ user.username }}</td>
</tr>
<tr>
<td><b>邮件:</b></td>
<td>{{ user.email }}</td>
</tr>
{% if user.phone %}
<tr>
<td><b>手机:</b></td>
<td>{{ user.phone }}</td>
</tr>
{% endif %}
{% if user.wechat %}
<tr>
<td><b>微信:</b></td>
<td>{{ user.wechat }}</td>
</tr>
{% endif %}
<tr>
<td><b>角色:</b></td>
<td>{{ user.role.name }}</td>
</tr>
<tr>
<td><b>有效期:</b></td>
<td>{{ user.date_expired|date:"Y-m-j H:i:s" }}</td>
</tr>
<tr>
<td><b>创建者:</b></td>
<td>{{ user.created_by }}</td>
</tr>
<tr>
<td><b>创建日期:</b></td>
<td>{{ user.date_joined|date:"Y-m-j H:i:s" }}</td>
</tr>
<tr>
<td><b>最后登录:</b></td>
<td>{{ user.last_login|date:"Y-m-j H:i:s" }}</td>
</tr>
<tr>
<td><b>描述:</b></td>
<td>{{ user.comment }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-sm-5" style="padding-left: 0px;">
<div class="ibox float-e-margins">
<div class="ibox-title " style="background: #1ab394">
<span style="color: white">快速修改</span>
<div class="ibox-tools">
</div>
</div>
<div class="ibox-content" style="border-color: #1ab394; border-style: solid solid solid; border-width: 1px" >
<table class="table">
<tbody>
<tr>
<td colspan="2">
<img src="{% static "img/root.png" %}" class="img-circle" width="64" height="64">
</td>
</tr>
<tr>
<td width="20%"><b>姓名:</b></td>
<td>{{ user.name }}</td>
</tr>
<tr>
<td><b>描述:</b></td>
<td>{{ user.comment }}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="ibox float-e-margins">
<div class="ibox-title bg-primary">
<span class="label"><b>{{ user.name }}</b></span>
<div class="ibox-tools">
</div>
</div>
<div class="ibox-content">
<table class="table">
<tbody>
<tr>
<td colspan="2">
<img src="{% static "img/root.png" %}" class="img-circle", width="64" height="64">
</td>
</tr>
<tr>
<td width="20%"><b>姓名:</b></td>
<td>{{ user.name }}</td>
</tr>
<tr>
<td><b>描述:</b></td>
<td>{{ user.comment }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% extends 'users/_user.html' %}
{% block username %}
<div class="form-group">
<label for="{{ form.username.id_for_label }}" class="col-sm-2 control-label">用户名</label>
<div class="col-sm-9 controls" >
<input id="{{ form.username.id_for_label }}" name="username" type="text" value="{{ form.username.value }}" readonly class="form-control">
</div>
</div>
{% endblock %}
{% block password %}
<h3>密码</h3>
<div class="form-group">
......
......@@ -58,7 +58,7 @@
<input type="checkbox" name="checked" value="{{ user.id }}">
</td>
<td class="text-center">
<a href="{% url 'users:user-detail' pk=user.id %}?id={{ user.id }}">
<a href="{% url 'users:user-detail' pk=user.id %}">
{{ user.name }}
</a>
</td>
......
from django.conf.urls import url
from .views import UserListView, UserAddView, UserUpdateView
from .views import UserListView, UserAddView, UserUpdateView, UserDeleteView, UserDetailView
app_name = 'users'
urlpatterns = [
url(r'^$', UserListView.as_view(), name='user-list'),
url(r'^(?P<pk>[0-9]+)/$', UserListView.as_view(), name='user-detail'),
url(r'^(?P<pk>[0-9]+)/$', UserDetailView.as_view(), name='user-detail'),
url(r'^add/$', UserAddView.as_view(), name='user-add'),
url(r'^(?P<pk>[0-9]+)/edit/$', UserUpdateView.as_view(), name='user-edit'),
url(r'^(?P<pk>[0-9]+)/delete/$', UserListView.as_view(), name='user-delete'),
url(r'^(?P<pk>[0-9]+)/delete/$', UserDeleteView.as_view(), name='user-delete'),
]
......@@ -4,6 +4,7 @@ from django.urls import reverse_lazy
from django.db.models import Q
from django.views.generic.list import ListView
from django.views.generic.edit import CreateView, DeleteView, UpdateView
from django.views.generic.detail import DetailView
from .models import User, UserGroup, Role
from .forms import UserForm
......@@ -44,8 +45,8 @@ class UserAddView(CreateView):
def form_valid(self, form):
user = form.save()
password = form['password'].value()
user.set_password(password)
user.created_by = self.request.user.username or 'Admin'
user.save()
return super(UserAddView, self).form_valid(form)
......@@ -57,7 +58,19 @@ class UserUpdateView(UpdateView):
def form_valid(self, form):
user = form.save()
password = form['password'].value()
password = self.request.POST.get('password', '')
if password:
user.set_password(password)
return super(UserUpdateView, self).form_valid(form)
class UserDeleteView(DeleteView):
model = User
success_url = reverse_lazy('users:user-list')
template_name = 'users/user_delete_confirm.html'
class UserDetailView(DeleteView):
model = User
template_name = 'users/user_detail.html'
context_object_name = "user"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment