-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from dev-backend
- Loading branch information
Showing
46 changed files
with
2,486 additions
and
716 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.urls import path | ||
from .views import * | ||
|
||
app_name = "device" | ||
urlpatterns = [ | ||
path('list', DeviceFileListView.as_view(), name='list'), # TODO | ||
path('add', DeviceFileCreateView.as_view(), name='add'), | ||
path('update/<int:pk>', DeviceFileUpdatView.as_view(), name='update'), | ||
path('delete/<int:pk>', DeviceFileDetailView.as_view(), name='delete'), | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
from django.shortcuts import render | ||
from django.views.generic import ListView, CreateView, UpdateView, DeleteView, DetailView, TemplateView | ||
|
||
# Create your views here. | ||
|
||
class DeviceFileListView(TemplateView): | ||
template_name = "device/device.html" | ||
|
||
|
||
class DeviceFileCreateView(CreateView): | ||
template_name = "TEMPLATE_NAME" | ||
|
||
|
||
class DeviceFileUpdatView(UpdateView): | ||
template_name = "TEMPLATE_NAME" | ||
|
||
|
||
class DeviceFileDeleteView(DeleteView): | ||
template_name = "TEMPLATE_NAME" | ||
|
||
|
||
class DeviceFileDetailView(DetailView): | ||
template_name = "TEMPLATE_NAME" |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 2.1.3 on 2019-01-24 08:15 | ||
|
||
import core.utils | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('safety', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='safetyfile', | ||
name='file_s', | ||
field=models.FileField(blank=True, null=True, upload_to='safety/%Y/%m/%d/', validators=[core.utils.validate_file_extension], verbose_name='文件'), | ||
), | ||
] |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.urls import path | ||
from .views import * | ||
|
||
app_name = "schedule" | ||
urlpatterns = [ | ||
path('list', ScheduleListView.as_view(), name='list'), | ||
path('detail', ScheduleDetailView.as_view(), name='detail'), | ||
path('chart', ScheduleChartView.as_view(), name='chart'), | ||
path('item', ScheduleItemChartView.as_view(), name='item'), | ||
path('add', ScheduleFileCreateView.as_view(), name='add'), | ||
path('update/<int:pk>', ScheduleFileUpdatView.as_view(), name='update'), | ||
path('delete/<int:pk>', ScheduleFileDetailView.as_view(), name='delete'), | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
from django.shortcuts import render | ||
from django.views.generic import ListView, CreateView, UpdateView, DeleteView, DetailView, TemplateView | ||
|
||
|
||
# Create your views here. | ||
|
||
|
||
class ScheduleListView(TemplateView): | ||
template_name = "schedule/schedule.html" | ||
|
||
|
||
class ScheduleDetailView(TemplateView): | ||
template_name = "schedule/schedule_detail.html" | ||
|
||
|
||
class ScheduleChartView(TemplateView): | ||
template_name = "schedule/schedule_chart.html" | ||
|
||
|
||
class ScheduleItemChartView(TemplateView): | ||
template_name = "schedule/schedule_item.html" | ||
|
||
|
||
class ScheduleFileCreateView(CreateView): | ||
template_name = "TEMPLATE_NAME" | ||
|
||
|
||
class ScheduleFileUpdatView(UpdateView): | ||
template_name = "TEMPLATE_NAME" | ||
|
||
|
||
class ScheduleFileDeleteView(DeleteView): | ||
template_name = "TEMPLATE_NAME" | ||
|
||
|
||
class ScheduleFileDetailView(DetailView): | ||
template_name = "TEMPLATE_NAME" | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
django-bootstrap-modal-forms | ||
version : 1.3.1 | ||
Copyright (c) 2018 Uros Trstenjak | ||
https://github.com/trco/django-bootstrap-modal-forms | ||
*/ | ||
|
||
(function ($) { | ||
|
||
// Open modal & load the form at formURL to the modalContent element | ||
var newForm = function (modalID, modalContent, modalForm, formURL, errorClass, submitBtn) { | ||
$(modalContent).load(formURL, function () { | ||
$(modalID).modal("show"); | ||
$(modalForm).attr("action", formURL); | ||
// Add click listener to the submitBtn | ||
ajaxSubmit(modalID, modalContent, modalForm, formURL, errorClass, submitBtn); | ||
}); | ||
}; | ||
|
||
// Add click listener to the submitBtn | ||
var ajaxSubmit = function (modalID, modalContent, modalForm, formURL, errorClass, submitBtn) { | ||
$(submitBtn).on("click", function () { | ||
// Check if form.is_valid() via ajax request | ||
var formIsValid = isFormValid(modalID, modalContent, modalForm, formURL, errorClass); | ||
if (formIsValid) { | ||
// Submit form if form.is_valid() | ||
$(modalForm).submit(); | ||
} else { | ||
// Reinstantiate click listener on submitBtn | ||
// Form is updated with errors in isFormValid(...) call | ||
ajaxSubmit(modalID, modalContent, modalForm, formURL, errorClass, submitBtn); | ||
} | ||
}); | ||
}; | ||
|
||
// Check if form.is_valid() | ||
var isFormValid = function (modalID, modalContent, modalForm, formURL, errorClass) { | ||
var formIsValid = true; | ||
$.ajax({ | ||
type: $(modalForm).attr("method"), | ||
url: $(modalForm).attr("action"), | ||
async: false, | ||
// Serialize form data | ||
data: new FormData($(modalForm)[0]), | ||
cache: false, | ||
contentType: false, | ||
processData: false, | ||
success: function (response) { | ||
if ($(response).find(errorClass).length > 0) { | ||
formIsValid = false; | ||
// Update form with errors if not form.is_valid() | ||
$(modalID).find(modalContent).html(response); | ||
$(modalForm).attr("action", formURL); | ||
} | ||
} | ||
}); | ||
return formIsValid; | ||
}; | ||
|
||
|
||
$.fn.modalForm = function (options) { | ||
// Default settings | ||
var defaults = { | ||
modalID: "#modal", | ||
modalContent: ".modal-content", | ||
modalForm: ".modal-content form", | ||
formURL: null, | ||
errorClass: ".invalid", | ||
submitBtn: ".submit-btn" | ||
}; | ||
|
||
// Extend default settings with provided options | ||
var settings = $.extend(defaults, options); | ||
|
||
return this.each(function () { | ||
// Add click listener to the element with attached modalForm | ||
$(this).click(function (event) { | ||
// Instantiate new modalForm in modal | ||
newForm(settings.modalID, | ||
settings.modalContent, | ||
settings.modalForm, | ||
settings.formURL, | ||
settings.errorClass, | ||
settings.submitBtn); | ||
}); | ||
}); | ||
}; | ||
|
||
}(jQuery)); |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.