-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.py
107 lines (88 loc) · 2.43 KB
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from django.forms import ModelForm
from leaflet.forms.widgets import LeafletWidget
from .models import Drawing, Dxf2Csv, Insertion, Layer
class DrawingCreateForm(ModelForm):
class Meta:
model = Drawing
fields = ["title", "intro", "dxf", "image", "private"]
class DrawingGeoDataForm(ModelForm):
class Meta:
model = Drawing
fields = ["geom", "designx", "designy", "rotation"]
widgets = {
"geom": LeafletWidget(
attrs={
"geom_type": "Point",
}
)
}
class Media:
js = ("djeocad/js/locate_user.js",)
class DrawingUpdateForm(ModelForm):
class Meta:
model = Drawing
fields = [
"title",
"intro",
"dxf",
"image",
"geom",
"designx",
"designy",
"rotation",
"private",
]
widgets = {
"geom": LeafletWidget(
attrs={
"geom_type": "Point",
}
)
}
class DrawingSimpleCreateForm(ModelForm):
class Meta:
model = Drawing
fields = ["title", "intro", "dxf"]
class LayerCreateForm(ModelForm):
class Meta:
model = Layer
fields = ["name", "color_field", "linetype", "geom"]
widgets = {
"geom": LeafletWidget(
attrs={
"geom_type": "GeometryCollection",
}
)
}
class Media:
js = ("djeocad/js/locate_drawing.js",)
class InsertionCreateForm(ModelForm):
def __init__(self, **kwargs):
super(InsertionCreateForm, self).__init__(**kwargs)
# filter layer queryset
layer = Layer.objects.get(id=self.initial["layer"])
self.fields["layer"].queryset = Layer.objects.filter(
drawing_id=layer.drawing.id, is_block=False
)
class Meta:
model = Insertion
fields = [
"layer",
"point",
"rotation",
"x_scale",
"y_scale",
]
widgets = {
"point": LeafletWidget(
attrs={
"geom_type": "Point",
}
)
}
class Media:
js = ("djeocad/js/locate_drawing.js",)
class Dxf2CsvCreateForm(ModelForm):
class Meta:
model = Dxf2Csv
fields = ["dxf", "intro"]