This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @admin.register(m.Holiday) | |
| class HolidayAdmin(admin.ModelAdmin): | |
| list_display = ('id', 'day', 'category') | |
| search_fields = ('day',) | |
| list_filter = ('category',) | |
| date_hierarchy = 'day' | |
| def get_form(self, request, obj=None, change=False, **kwargs): | |
| if not change: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BudgetInline(admin.TabularInline): | |
| class Media: | |
| js = (JQUERY_MIN_JS, ) | |
| model = m.Budget | |
| exclude = ['department', ] | |
| readonly_fields = ['available_amount', ] | |
| form = forms.BudgetAdminForm | |
| @admin.register(m.Budget) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @admin.register(m.Project) | |
| class ProjectAdmin(admin.ModelAdmin): | |
| formfield_overrides = { | |
| models.DecimalField: {'widget': widgets.DecimalInput}, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| from collections import OrderedDict | |
| from copy import deepcopy | |
| from django.core.exceptions import ValidationError | |
| from django.utils.encoding import force_str | |
| from import_export import resources, widgets | |
| from . import models as m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| # pip install python-docx | |
| def get_all_python_files(directory): | |
| import os, pathlib | |
| all_python_files = list(pathlib.Path(os.path.expanduser(directory)).glob('./**/[!config]*/*.py')) | |
| all_python_files.extend(list(pathlib.Path(os.path.expanduser(directory)).glob('*.py'))) | |
| return all_python_files | |
| def is_not_excluded_text(line): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @admin.register(WBS) | |
| class WBSAdmin(admin.ModelAdmin): | |
| list_display = ( | |
| 'id', | |
| 'code', | |
| 'name', | |
| 'parent', | |
| 'pv', | |
| 'ev', | |
| 'created', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_changeform_initial_data(self, request): | |
| init = super().get_changeform_initial_data(request) | |
| init['company'] = get_user_last_company(request.user) | |
| return init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_fields(self, request, obj=None): | |
| if not obj: | |
| # 新增页面的字段 | |
| fields = ['name', 'company', 'project'] | |
| else: | |
| # 修改页面的字段 | |
| fields = super().get_fields(request, obj) | |
| return fields |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function findGetParameter(parameterName) { | |
| var result = null, | |
| tmp = []; | |
| location.search | |
| .substr(1) | |
| .split("&") | |
| .forEach(function (item) { | |
| tmp = item.split("="); | |
| if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from IPython import embed;embed() |