Skip to content

Commit c4e4a13

Browse files
committed
front-finished, back-finished
1 parent 509f320 commit c4e4a13

File tree

28 files changed

+17457
-305
lines changed

28 files changed

+17457
-305
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# my_project_app/apps.py
2+
from suit.apps import DjangoSuitConfig
3+
from suit.menu import ParentItem, ChildItem
4+
5+
6+
class SuitConfig(DjangoSuitConfig):
7+
menu = (
8+
9+
ParentItem('Content', children=[
10+
ChildItem(model='cargos_main.cargo'),
11+
ChildItem(model='cargos_main.cell'),
12+
ChildItem(model='cargos_main.storage'),
13+
], icon='fa fa-archive'),
14+
ParentItem('Users', children=[
15+
ChildItem(model='auth.user'),
16+
], icon='fa fa-users'),
17+
ParentItem('Notifications', children=[
18+
ChildItem(model='notifications.notification'),
19+
], icon='fa fa-exclamation'),
20+
ParentItem('Right Side Menu', children=[
21+
ChildItem('Password change', url='admin:password_change'),
22+
ChildItem('Open Google', url='http://google.com', target_blank=True),
23+
24+
], align_right=True, icon='fa fa-cog'),
25+
)
26+
layout = 'vertical'
27+
28+
def ready(self):
29+
super(SuitConfig, self).ready()
30+
31+
# DO NOT COPY FOLLOWING LINE
32+
# It is only to prevent updating last_login in DB for demo app
33+
self.prevent_user_last_login()
34+
35+
def prevent_user_last_login(self):
36+
"""
37+
Disconnect last login signal
38+
"""
39+
from django.contrib.auth import user_logged_in
40+
from django.contrib.auth.models import update_last_login
41+
user_logged_in.disconnect(update_last_login)

cargos_backend/cargos_backend/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
# Application definition
4646

4747
INSTALLED_APPS = [
48+
'cargos_backend.apps.SuitConfig',
4849
'django.contrib.admin',
4950
'django.contrib.auth',
5051
'django.contrib.contenttypes',

cargos_backend/cargos_main/cargos_saving.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def save_cargo(data):
2424
'height': data.get('height', 1),
2525
'length': data.get('length', 1),
2626
'width': data.get('width', 1),
27-
'rotatable': data.get('rotatable', 'off')
27+
'rotatable': data.get('rotatable', 'No')
2828
},
2929
new_cell_vals,
3030
storage.rows, storage.elevations, storage.positions
@@ -73,7 +73,7 @@ def add_cargo_fields(new_row, new_el, new_pos, data):
7373
new_cargo_obj.height = data.get('height', 1)
7474
new_cargo_obj.width = data.get('width', 1)
7575
new_cargo_obj.length = data.get('length', 1)
76-
new_cargo_obj.rotatable = True if data.get('rotatable', 'off') == 'on' else False
76+
new_cargo_obj.rotatable = True if data.get('rotatable', 'No') == 'Yes' else False
7777

7878
new_cargo_obj.save()
7979

cargos_backend/cargos_main/forms.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ class NewCargoForm(forms.Form):
2424
date_added = forms.DateTimeField(initial=dt.datetime.now, localize=True,
2525
widget=forms.TextInput(
2626
attrs={'type': 'date'}
27-
), required=False)
27+
), required=True)
2828
date_dated = forms.DateField(
2929
required=True,
3030
widget=forms.TextInput(
31-
attrs={'type': 'date', 'value': '111'}
31+
attrs={'type': 'date'}
3232
),
3333
initial=dt.datetime.now,
3434
localize=True
3535
)
3636

37-
rotatable = forms.BooleanField(label='Rotatable', required=False)
37+
rotatable = forms.BooleanField(label='Rotatable', required=False, widget=forms.NullBooleanSelect)
3838

3939
# Widgets
4040
title.widget = forms.TextInput()
4141
description.widget = forms.Textarea()
4242
storage.widget = forms.Select()
4343

4444
date_added.widget.attrs.update({'placeholder': 'Select a date', })
45-
date_dated.widget.attrs.update({'placeholder': 'Select a date', 'class': 'col-md-7'})
45+
date_dated.widget.attrs.update({'placeholder': 'Select a date', })
4646

4747
height.widget.attrs.update({'placeholder': '0.01...100', })
4848
length.widget.attrs.update({'placeholder': '0.01...100', })

cargos_backend/cargos_main/models.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import datetime as dt
22

33
from django.core.exceptions import ValidationError
4+
from django.core.validators import MinValueValidator, MaxValueValidator
45
from django.db import models
56

67

78
class Storage(models.Model):
89
name = models.CharField(max_length=200, null=True)
910

10-
rows = models.IntegerField()
11-
elevations = models.IntegerField() # y
12-
positions = models.IntegerField() # x
11+
rows = models.IntegerField(validators=[MinValueValidator(1),
12+
MaxValueValidator(100)])
13+
elevations = models.IntegerField(validators=[MinValueValidator(1),
14+
MaxValueValidator(100)]) # y
15+
positions = models.IntegerField(validators=[MinValueValidator(1),
16+
MaxValueValidator(100)]) # x
1317

1418
default_height = models.DecimalField(decimal_places=2, max_digits=9, default=1)
1519
default_length = models.DecimalField(decimal_places=2, max_digits=9, default=1)
@@ -45,7 +49,6 @@ def clean(self):
4549

4650

4751
class Cargo(models.Model):
48-
4952
cell = models.ForeignKey(Cell, on_delete=models.CASCADE)
5053

5154
height = models.DecimalField(decimal_places=2, max_digits=9, default=1)
@@ -67,3 +70,12 @@ def __str__(self):
6770
# super().clean()
6871
# try:
6972
# parse(self.date_dated)
73+
74+
75+
class Droid(models.Model):
76+
title = models.CharField(max_length=200, null=True)
77+
78+
cargo = models.ForeignKey(Cargo, on_delete=models.SET_NULL, null=True)
79+
80+
def __str__(self):
81+
return f'{str(self.title)} - {str(self.id)}'
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
{% extends "../../utils/wrappers/wrapper.html" %}
1+
{% extends "utils/wrappers/wrapper.html" %}
22

3-
{% block title %}Controller{% endblock %}
3+
{% block title %}Coordinate A.{% endblock %}
44

55
{% block content %}
6-
{% include '../../utils/includes/index_page_template/carousel_cargos.html' %}
7-
{% include '../../utils/includes/search_form.html' %}
6+
{% include 'utils/includes/index_page_template/carousel_cargos.html' %}
7+
{% include 'utils/includes/search_form.html' %}
88
{% endblock %}

cargos_backend/cargos_main/templates/managing_cargos/delete_cargo/delete_cargo.html

Lines changed: 107 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,111 @@
33
{% block title %}Delete Cargo{% endblock %}
44

55
{% block content %}
6-
<h1 class="text-center text-secondary"> Delete Cargo </h1>
7-
<div class="container-fluid">
8-
<form method="post" action="#">
9-
{% csrf_token %}
10-
<table class="table table-hover table-bordered table-striped">
11-
<tr>
12-
<td>Cargo: </td>
13-
<td>{{ cargo }}</td>
14-
</tr>
15-
</table>
16-
<input type="submit" value="Delete" class="btn btn-primary">
17-
</form>
18-
</div>
6+
{% load static i18n %}
7+
<!--================Order Details Area =================-->
8+
<section class="order_details section_gap">
9+
<div class="container">
10+
<h3 class="title_confirmation">Are you sure, that you want to delete this cargo?.</h3>
11+
<div class="row order_d_inner d-flex justify-content-center">
12+
<div class="col-lg-6">
13+
<div class="details_item">
14+
<h4>{{ cargo.title }}</h4>
15+
<ul class="list">
16+
<li><a href="#"><span>Cargo id</span> : {{ cargo.id }}</a></li>
17+
<li><a href="#"><span>Date</span> : {{ cargo.date_dated }}</a></li>
18+
<li><a href="#"><span>Cell</span> : {{ cargo.cell }}</a></li>
19+
<li><a href="#"><span>Rotatable</span> : {{ cargo.rotatable }}</a></li>
20+
</ul>
21+
</div>
22+
</div>
23+
</div>
24+
<div class="order_details_table">
25+
<h2>Cargo Details</h2>
26+
<div class="table-responsive">
27+
<table class="table">
28+
<thead>
29+
<tr>
30+
<th scope="col">Parameter</th>
31+
<th scope="col">Numeric</th>
32+
<th scope="col">Description</th>
33+
</tr>
34+
</thead>
35+
<tbody>
36+
<tr>
37+
<td>
38+
<p>{% trans 'Width' %}</p>
39+
</td>
40+
<td>
41+
<h5>{{ cargo.width }}</h5>
42+
</td>
43+
<td>
44+
<p> - </p>
45+
</td>
46+
</tr>
47+
<tr>
48+
<td>
49+
<p>{% trans 'Height' %}</p>
50+
</td>
51+
<td>
52+
<h5>{{ cargo.height }}</h5>
53+
</td>
54+
<td>
55+
<p> - </p>
56+
</td>
57+
</tr>
58+
<tr>
59+
<td>
60+
<p>{% trans 'Length' %}</p>
61+
</td>
62+
<td>
63+
<h5>{{ cargo.length }}</h5>
64+
</td>
65+
<td>
66+
<p> - </p>
67+
</td>
68+
</tr>
69+
<tr>
70+
<td>
71+
<h4>{% trans 'CELL' %}</h4>
72+
</td>
73+
<td>
74+
<h5></h5>
75+
</td>
76+
<td>
77+
<p>{{ cargo.cell }}</p>
78+
</td>
79+
</tr>
80+
<tr>
81+
<td>
82+
<h4>{% trans 'DATE ADDED' %}</h4>
83+
</td>
84+
<td>
85+
<h5></h5>
86+
</td>
87+
<td>
88+
<p>{{ cargo.date_added }}</p>
89+
</td>
90+
</tr>
91+
<tr>
92+
<td>
93+
<h4>{% trans 'DATE DATED' %}</h4>
94+
</td>
95+
<td>
96+
<h5></h5>
97+
</td>
98+
<td>
99+
<p>{{ cargo.date_dated }}</p>
100+
</td>
101+
</tr>
102+
</tbody>
103+
</table>
104+
<form method="post" action="#" class="d-flex justify-content-center mt-3">
105+
{% csrf_token %}
106+
<input type="submit" value="Delete" class="btn primary-btn">
107+
</form>
108+
</div>
109+
</div>
110+
</div>
111+
</section>
112+
<!--================End Order Details Area =================-->
19113
{% endblock %}
Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,42 @@
11
{% load crispy_forms_tags %}
2+
{% load static i18n %}
23

3-
<form action="#" method="post">
4-
{% csrf_token %}
5-
<div class="form-row">
6-
<div class="form-group col-md-6 mb-0">
7-
{{ form.title|as_crispy_field }}
8-
</div>
9-
<div class="form-group col-md-6 mb-0">
10-
{{ form.storage|as_crispy_field }}
11-
</div>
12-
</div>
13-
{{ form.height|as_crispy_field }}
14-
{{ form.length|as_crispy_field }}
15-
{{ form.width|as_crispy_field }}
16-
<div class="form-row">
17-
{{ form.description|as_crispy_field }}
18-
</div>
19-
<div class="form-row">
20-
<div class="form-group col-md-6">
21-
{{ form.date_added|as_crispy_field }}
22-
{{ form.date_added|as_crispy_field }}
4+
<div class="container mt-5 mb-3">
5+
<div class="returning_customer">
6+
7+
<div class="row d-flex justify-content-center">
8+
<div class="check_title mb-3 col-md-9">
9+
<h2>{% trans 'Want to see the existing cargos?' %} <a
10+
href="{% url 'preview_cargos' %}">{% trans 'Click here to go' %}</a></h2>
11+
</div>
12+
<form class="contact_form col-md-10" action="#" method="post">
13+
{% csrf_token %}
14+
<div class="form-row">
15+
<div class="form-group col-md-4 mb-0">
16+
{{ form.title|as_crispy_field }}
17+
</div>
18+
<div class="form-group col-md-4 mb-0">
19+
{{ form.storage|as_crispy_field }}
20+
</div>
21+
<div class="form-group col-md-4 mb-0">
22+
{{ form.rotatable|as_crispy_field }}
23+
</div>
24+
</div>
25+
{{ form.height|as_crispy_field }}
26+
{{ form.length|as_crispy_field }}
27+
{{ form.width|as_crispy_field }}
28+
<div class="form-row">
29+
{{ form.description|as_crispy_field }}
30+
<div class="form-group col-md-6">
31+
{{ form.date_added|as_crispy_field }}
32+
{{ form.date_dated|as_crispy_field }}
33+
</div>
34+
</div>
35+
36+
<div class="col-md-12 form-group row d-flex justify-content-center">
37+
<button type="submit" class="btn primary-btn">Add cargo</button>
38+
</div>
39+
</form>
2340
</div>
2441
</div>
25-
{{ form.rotatable|as_crispy_field }}
26-
<input type="submit" class="btn btn-primary" value="Submit">
27-
</form>
42+
</div>

cargos_backend/cargos_main/templates/managing_cargos/new_cargo/new_cargo.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
{% block content %}
66
<div class="container">
7-
<h1 class="text-secondary text-center">Add cargo</h1>
87
{% include 'managing_cargos/new_cargo/create_new_cargo.html' %}
98
</div>
109

0 commit comments

Comments
 (0)