mirror of https://github.com/raiots/TasksManager
add: 承办人与协办人只显示本部门人员,Index中仅显示本部门统计,部门任务界面按编号+完成时间排序
This commit is contained in:
parent
42ce5e6fc8
commit
8b4d29a71d
|
@ -4,10 +4,23 @@ from django.contrib import admin
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
from apps.users.models import TaskProperty
|
from apps.users.models import TaskProperty, User
|
||||||
|
|
||||||
|
|
||||||
class TodoInline(admin.StackedInline):
|
class TodoInline(admin.StackedInline):
|
||||||
|
|
||||||
|
# 在Inline中同样筛选仅本部门的承办人、协办人
|
||||||
|
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
||||||
|
if db_field.name == 'related_task':
|
||||||
|
kwargs["queryset"] = models.Task.objects.filter(department=request.user.department)
|
||||||
|
elif db_field.name == 'main_executor':
|
||||||
|
kwargs["queryset"] = User.objects.filter(department=request.user.department)
|
||||||
|
return super().formfield_for_foreignkey(db_field, request, **kwargs)
|
||||||
|
|
||||||
|
def formfield_for_manytomany(self, db_field, request, **kwargs):
|
||||||
|
if db_field.name == 'sub_executor':
|
||||||
|
kwargs["queryset"] = User.objects.filter(department=request.user.department)
|
||||||
|
return super().formfield_for_manytomany(db_field, request, **kwargs)
|
||||||
model = models.Todo
|
model = models.Todo
|
||||||
extra = 0
|
extra = 0
|
||||||
# classes = ['collapse']
|
# classes = ['collapse']
|
||||||
|
@ -57,18 +70,26 @@ class TaskAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
class TodoAdmin(admin.ModelAdmin):
|
class TodoAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
# 工作包页面仅显示所属本部门的年度任务
|
# 工作包页面仅显示所属本部门的年度任务、承办人、协办人
|
||||||
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
||||||
if db_field.name == 'related_task':
|
if db_field.name == 'related_task':
|
||||||
kwargs["queryset"] = models.Task.objects.filter(department=request.user.department)
|
kwargs["queryset"] = models.Task.objects.filter(department=request.user.department)
|
||||||
|
elif db_field.name == 'main_executor':
|
||||||
|
kwargs["queryset"] = User.objects.filter(department=request.user.department)
|
||||||
return super().formfield_for_foreignkey(db_field, request, **kwargs)
|
return super().formfield_for_foreignkey(db_field, request, **kwargs)
|
||||||
|
|
||||||
|
def formfield_for_manytomany(self, db_field, request, **kwargs):
|
||||||
|
if db_field.name == 'sub_executor':
|
||||||
|
kwargs["queryset"] = User.objects.filter(department=request.user.department)
|
||||||
|
return super().formfield_for_manytomany(db_field, request, **kwargs)
|
||||||
|
|
||||||
fieldsets = [
|
fieldsets = [
|
||||||
(None, {
|
(None, {
|
||||||
'fields': [
|
'fields': [
|
||||||
'related_task', 'todo_topic', 'todo_note', 'deadline', 'duty_group', 'main_executor', 'sub_executor',
|
'related_task', 'todo_topic', 'todo_note', 'deadline', 'duty_group', 'main_executor', 'sub_executor',
|
||||||
'predict_work', 'evaluate_factor',
|
'predict_work', 'evaluate_factor',
|
||||||
]
|
],
|
||||||
|
'description': []
|
||||||
}),
|
}),
|
||||||
|
|
||||||
(None, {
|
(None, {
|
||||||
|
@ -96,7 +117,7 @@ class TodoAdmin(admin.ModelAdmin):
|
||||||
list_display_links = ('todo_topic', 'deadline', )
|
list_display_links = ('todo_topic', 'deadline', )
|
||||||
date_hierarchy = 'deadline'
|
date_hierarchy = 'deadline'
|
||||||
list_per_page = 70 # 目的是取消自动分页,好像有bug
|
list_per_page = 70 # 目的是取消自动分页,好像有bug
|
||||||
raw_id_fields = ("main_executor", "sub_executor")
|
# raw_id_fields = ("sub_executor",)
|
||||||
search_fields = ('todo_topic',)
|
search_fields = ('todo_topic',)
|
||||||
ordering = ('related_task', )
|
ordering = ('related_task', )
|
||||||
|
|
||||||
|
@ -120,11 +141,7 @@ class TodoAdmin(admin.ModelAdmin):
|
||||||
return obj.related_task
|
return obj.related_task
|
||||||
lined_task.short_description = '任务名称'
|
lined_task.short_description = '任务名称'
|
||||||
|
|
||||||
# TODO 增加承办人与协办人只显示本部门人员
|
|
||||||
# TODO 任务编辑界面按部门显示
|
# TODO 任务编辑界面按部门显示
|
||||||
# TODO 修复工作事项显示不下自动分页,取消自动分页
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(models.Task, TaskAdmin)
|
admin.site.register(models.Task, TaskAdmin)
|
||||||
|
|
|
@ -6,11 +6,15 @@ class LoginForm(forms.Form):
|
||||||
password = forms.CharField()
|
password = forms.CharField()
|
||||||
remember = forms.BooleanField(required=False)
|
remember = forms.BooleanField(required=False)
|
||||||
|
|
||||||
|
|
||||||
class TodoForm(forms.ModelForm):
|
class TodoForm(forms.ModelForm):
|
||||||
|
required_css_class = 'required'
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Todo
|
model = Todo
|
||||||
fields = ['maturity', 'real_work', 'complete_note']
|
fields = ['maturity', 'real_work', 'complete_note']
|
||||||
labels ={'text': ''}
|
labels ={'text': ''}
|
||||||
widgets = {'rows': '3'}
|
widgets = {'rows': '3'}
|
||||||
|
|
||||||
|
|
||||||
# TODO 数据不可为空
|
# TODO 数据不可为空
|
|
@ -15,7 +15,7 @@ from apps.users.models import User
|
||||||
class IndexView(View):
|
class IndexView(View):
|
||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
users = User.objects.all()
|
users = User.objects.filter(department=request.user.department)
|
||||||
# points = []
|
# points = []
|
||||||
# point = User.objects.all()
|
# point = User.objects.all()
|
||||||
# for i in point:
|
# for i in point:
|
||||||
|
@ -39,7 +39,8 @@ class TodoListView(View):
|
||||||
class GroupTodoList(View):
|
class GroupTodoList(View):
|
||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
def get(self, request, year=timezone.now().year, month=timezone.now().month):
|
def get(self, request, year=timezone.now().year, month=timezone.now().month):
|
||||||
group_todo = Todo.objects.filter(main_executor__department=request.user.department, deadline__year=year, deadline__month=month)
|
group_todo = Todo.objects.filter(main_executor__department=request.user.department, deadline__year=year,
|
||||||
|
deadline__month=month).order_by('related_task_id', 'deadline')
|
||||||
date = str(year) + '年' + str(month) + '月'
|
date = str(year) + '年' + str(month) + '月'
|
||||||
context = {'group_todo': group_todo, 'date': date}
|
context = {'group_todo': group_todo, 'date': date}
|
||||||
return render(request, 'tasks/group_todolist.html', context)
|
return render(request, 'tasks/group_todolist.html', context)
|
||||||
|
@ -85,7 +86,7 @@ class TodoEntryView(View):
|
||||||
form = TodoForm(instance=todo_detail, data=request.POST)
|
form = TodoForm(instance=todo_detail, data=request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
form.save()
|
form.save()
|
||||||
return redirect('tasks:index')
|
return redirect('tasks:todolist')
|
||||||
# return redirect('tasks:todo_detail', pk=pk)
|
# return redirect('tasks:todo_detail', pk=pk)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,12 @@
|
||||||
<table class="table" style="word-break: break-all">
|
<table class="table" style="word-break: break-all">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 10px; text-align:center; vertical-align: middle;">#</th>
|
<th style="width: 16px; text-align:center; vertical-align: middle;">#</th>
|
||||||
<th style="width: 280px; text-align:center; vertical-align: middle;">工作事项</th>
|
<th style="width: 280px; text-align:center; vertical-align: middle;">工作事项</th>
|
||||||
<th style="width: 100px; text-align:center; vertical-align: middle;">完成时间</th>
|
<th style="width: 100px; text-align:center; vertical-align: middle;">完成时间</th>
|
||||||
<th style="width: 160px; text-align:center; vertical-align: middle;">工作要求及交付物</th>
|
<th style="width: 160px; text-align:center; vertical-align: middle;">工作要求及交付物</th>
|
||||||
|
<th style="width: 50px; text-align:center; vertical-align: middle;">任务编号</th>
|
||||||
|
<th style="width: 120px; text-align:center; vertical-align: middle;">任务来源</th>
|
||||||
<th style="width: 120px; text-align:center; vertical-align: middle;">承办单位</th>
|
<th style="width: 120px; text-align:center; vertical-align: middle;">承办单位</th>
|
||||||
<th style="width: 120px;text-align:center; vertical-align: middle;">承/督办人</th>
|
<th style="width: 120px;text-align:center; vertical-align: middle;">承/督办人</th>
|
||||||
<th style="width: 200px;text-align:center; vertical-align: middle;">协办人</th>
|
<th style="width: 200px;text-align:center; vertical-align: middle;">协办人</th>
|
||||||
|
@ -81,6 +83,8 @@
|
||||||
<td>{{ todo.todo_topic }}</td>
|
<td>{{ todo.todo_topic }}</td>
|
||||||
<td style="text-align: center">{{ todo.deadline | date:"m月d日" }}</td>
|
<td style="text-align: center">{{ todo.deadline | date:"m月d日" }}</td>
|
||||||
<td style="width: 160px"><textarea style="width:100%;overflow:hidden">{{ todo.todo_note }}</textarea></td>
|
<td style="width: 160px"><textarea style="width:100%;overflow:hidden">{{ todo.todo_note }}</textarea></td>
|
||||||
|
<td style="text-align: center">{{ todo.task_id }}</td>
|
||||||
|
<td style="text-align: center">{{ todo.task_origin }}</td>
|
||||||
<td style="text-align: center">{{ todo.duty_group }}</td>
|
<td style="text-align: center">{{ todo.duty_group }}</td>
|
||||||
<td style="text-align: center">{{ todo.main_executor}}</td>
|
<td style="text-align: center">{{ todo.main_executor}}</td>
|
||||||
<td style="text-align: center">{{ todo.sub_executor.all|join:", " }}</td>
|
<td style="text-align: center">{{ todo.sub_executor.all|join:", " }}</td>
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
<!-- BAR CHART -->
|
<!-- BAR CHART -->
|
||||||
<div class="card card-gray">
|
<div class="card card-gray">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title">部门工作统计表</h3>
|
<h3 class="card-title">本部门工作统计表</h3>
|
||||||
|
|
||||||
<div class="card-tools">
|
<div class="card-tools">
|
||||||
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i
|
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i
|
||||||
|
|
Loading…
Reference in New Issue