going on forwar added form dire in templates for more precise type handlin like date string and so on defalut havlues fo select is also working now
parent
d25a310cab
commit
81b21bc69b
|
|
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,20 +1,39 @@
|
||||
from minibase.blueprints.geography.models import Country, City, State, Region, Subregion
|
||||
|
||||
import minibase.blueprints.database.utils as dbUtils
|
||||
from sqlalchemy import case
|
||||
|
||||
def queryCountryNames():
|
||||
choices = Country.query.order_by(Country.name.asc())
|
||||
return choices
|
||||
|
||||
def queryCountryNamesWithDefault(defId):
|
||||
choices = dbUtils.queryNameWithDefaultId(Country,defId)
|
||||
return choices
|
||||
|
||||
|
||||
def queryStateNames():
|
||||
choices = State.query.order_by(State.name.asc())
|
||||
return choices
|
||||
|
||||
def queryStateNamesOfCuntry(id):
|
||||
choices = State.query.order_by(State.name.asc()).filter_by(country_id=id)
|
||||
def queryStateNamesWithDefault(defId):
|
||||
choices = dbUtils.queryNameWithDefaultId(State,defId)
|
||||
return choices
|
||||
|
||||
|
||||
def queryCityNames():
|
||||
choices = City.query.order_by(City.name.asc())
|
||||
return choices
|
||||
|
||||
def queryCityNamesWithDefault(defId):
|
||||
choices = dbUtils.queryNameWithDefaultId(City,defId)
|
||||
return choices
|
||||
|
||||
def queryCiytNamesOfStateWithDefId(defId, Filterid):
|
||||
table=City
|
||||
choices = table.query.order_by(case((table.id == defId, 0),else_=1), table.name.asc()).filter_by(state_id=Filterid)
|
||||
return choices
|
||||
|
||||
def queryStateNamesOfCuntryWithDefId(defId, Filterid):
|
||||
table=State
|
||||
choices = table.query.order_by(case((table.id == defId, 0),else_=1), table.name.asc()).filter_by(country_id=Filterid)
|
||||
return choices
|
||||
|
Binary file not shown.
@ -1,6 +1,15 @@
|
||||
from minibase.blueprints.main.models import Industries
|
||||
import minibase.blueprints.database.utils as dbUtils
|
||||
|
||||
from sqlalchemy import case
|
||||
|
||||
|
||||
def queryIndustryNames():
|
||||
choices = Industries.query.order_by(Industries.name.asc())
|
||||
return choices
|
||||
|
||||
def queryIndustryNamesWithDefault(defId):
|
||||
choices = dbUtils.queryNameWithDefaultId(Industries,defId)
|
||||
return choices
|
||||
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,117 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from flask_wtf.file import FileField, FileAllowed
|
||||
from wtforms import StringField, PasswordField, SubmitField, BooleanField, URLField, IntegerField, DateField, SelectField
|
||||
from wtforms.validators import DataRequired, Length, Email, EqualTo, ValidationError
|
||||
from iot.blueprints.sensor.models import nbiotDevice
|
||||
from datetime import date
|
||||
|
||||
class updateNbioDeviceUpdateForm(FlaskForm): # Defines the form class to be used for the user update
|
||||
name = StringField('Device Name', validators=[DataRequired(), Length(min=3, max=50)])
|
||||
device_id = StringField('Device Id', validators=[DataRequired(), Length(min=3, max=50)])
|
||||
serialNumber = StringField('Serial Number', validators=[DataRequired(), Length(min=3, max=50)])
|
||||
imsi = StringField('Imsi No', validators=[DataRequired(), Length(min=10, max=50)])
|
||||
iccid = StringField('Iccid No', validators=[DataRequired(), Length(min=10, max=100)])
|
||||
ip = StringField('Ip (ipv4)', validators=[DataRequired(), Length(min=7, max=15)])
|
||||
port = StringField('Port', validators=[DataRequired(), Length(min=3, max=10)])
|
||||
registration_date = DateField('Registration Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
|
||||
activation_date = DateField('Activation Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
|
||||
deactivation_date = DateField('Deactivation Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
|
||||
owner_id = SelectField('Owner', validators=[DataRequired()])
|
||||
user_id = SelectField('User')
|
||||
status_id = SelectField('Status', validators=[DataRequired()])
|
||||
type_id = SelectField('Type', validators=[DataRequired()])
|
||||
area_id = SelectField('Area', validators=[DataRequired()])
|
||||
|
||||
|
||||
submit = SubmitField(f'Update')
|
||||
|
||||
def __init__(self, current_device_id, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.current_device = nbiotDevice.query.get(current_device_id)
|
||||
|
||||
def validate_name(self, input):
|
||||
if input.data != self.current_device.name:
|
||||
content = nbiotDevice.query.filter_by(name=input.data).first()
|
||||
if content:
|
||||
raise ValidationError('That device name is taken please choose another one')
|
||||
|
||||
def validate_device_id(self, input):
|
||||
if input.data != self.current_device.device_id:
|
||||
content = nbiotDevice.query.filter_by(device_id=input.data).first()
|
||||
if content:
|
||||
raise ValidationError('That device id is taken please choose another one')
|
||||
|
||||
def validate_imsi(self, input):
|
||||
if input.data != self.current_device.imsi:
|
||||
content = nbiotDevice.query.filter_by(imsi=input.data).first()
|
||||
if content:
|
||||
raise ValidationError('That IMSI id is taken please choose another one')
|
||||
|
||||
def validate_iccid(self, input):
|
||||
if input.data != self.current_device.iccid:
|
||||
content = nbiotDevice.query.filter_by(iccid=input.data).first()
|
||||
if content:
|
||||
raise ValidationError('That ICCID id is taken please choose another one')
|
||||
|
||||
def validate_ip(self, input):
|
||||
if input.data != self.current_device.ip:
|
||||
content = nbiotDevice.query.filter_by(ip=input.data).first()
|
||||
if content:
|
||||
raise ValidationError('That IP id is taken please choose another one')
|
||||
|
||||
class updateNbioDeviceAddForm(FlaskForm): # Defines the form class to be used for the user update
|
||||
name = StringField('Device Name', validators=[DataRequired(), Length(min=3, max=50)])
|
||||
device_id = StringField('Device Id', validators=[DataRequired(), Length(min=3, max=50)])
|
||||
imsi = StringField('Imsi No', validators=[DataRequired(), Length(min=10, max=50)])
|
||||
iccid = StringField('Iccid No', validators=[DataRequired(), Length(min=10, max=100)])
|
||||
ip = StringField('Ip (ipv4)', validators=[Length(min=7, max=15)])
|
||||
port = StringField('Port', validators=[Length(min=3, max=10)])
|
||||
registration_date = DateField('Registration Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
|
||||
activation_date = DateField('Activation Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
|
||||
deactivation_date = DateField('Deactivation Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
|
||||
user_id = SelectField('Owner', validators=[DataRequired()])
|
||||
status_id = SelectField('Status', validators=[DataRequired()])
|
||||
type_id = SelectField('Type', validators=[DataRequired()])
|
||||
area_id = SelectField('Area', validators=[DataRequired()])
|
||||
|
||||
submit = SubmitField(f'Add')
|
||||
|
||||
def validate_name(self, input):
|
||||
content = nbiotDevice.query.filter_by(name=input.data).first()
|
||||
if content:
|
||||
raise ValidationError('That device name is taken please choose another one')
|
||||
|
||||
def validate_device_id(self, input):
|
||||
content = nbiotDevice.query.filter_by(device_id=input.data).first()
|
||||
if content:
|
||||
raise ValidationError('That device id is taken please choose another one')
|
||||
|
||||
def validate_imsi(self, input):
|
||||
content = nbiotDevice.query.filter_by(imsi=input.data).first()
|
||||
if content:
|
||||
raise ValidationError('That IMSI id is taken please choose another one')
|
||||
|
||||
def validate_iccid(self, input):
|
||||
content = nbiotDevice.query.filter_by(iccid=input.data).first()
|
||||
if content:
|
||||
raise ValidationError('That ICCID id is taken please choose another one')
|
||||
|
||||
def validate_ip(self, input):
|
||||
content = nbiotDevice.query.filter_by(ip=input.data).first()
|
||||
if content:
|
||||
raise ValidationError('That IP id is taken please choose another one')
|
||||
|
||||
|
||||
class updateRoleForm(FlaskForm):
|
||||
id = StringField('ID', render_kw={'disabled':''})
|
||||
role = StringField('Role', validators=[DataRequired(), Length(min=4, max=20)])
|
||||
description = StringField('Description', validators=[DataRequired(), Length(min=4, max=200)])
|
||||
submit = SubmitField()
|
||||
|
||||
|
||||
class updateRoleForm(FlaskForm):
|
||||
id = StringField('ID', render_kw={'disabled':''})
|
||||
role = StringField('Role', validators=[DataRequired(), Length(min=4, max=20)])
|
||||
description = StringField('Description', validators=[DataRequired(), Length(min=4, max=200)])
|
||||
submit = SubmitField()
|
||||
|
@ -0,0 +1,61 @@
|
||||
from iot.app import db
|
||||
from datetime import datetime
|
||||
|
||||
class nbiotDevice(db.Model):
|
||||
__tablename__ = 'nbiotDevice'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
name = db.Column(db.String(50), nullable=False)
|
||||
device_id = db.Column(db.String(30), nullable=False)
|
||||
imsi = db.Column(db.String(30), nullable=False)
|
||||
iccid = db.Column(db.String(50), nullable=False)
|
||||
ip = db.Column(db.String(20), nullable=True)
|
||||
port = db.Column(db.String(20), nullable=True)
|
||||
registration_date = db.Column(db.DateTime, nullable=True)
|
||||
activation_date = db.Column(db.DateTime, nullable=True)
|
||||
deactivation_date = db.Column(db.DateTime, nullable=True)
|
||||
created = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
|
||||
updated = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
owner_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=True)
|
||||
status_id = db.Column(db.Integer, db.ForeignKey('nbiotDeviceStatus.id'), nullable=False)
|
||||
type_id = db.Column(db.Integer, db.ForeignKey('nbiotDeviceType.id'), nullable=False)
|
||||
area_id = db.Column(db.Integer, db.ForeignKey('nbiotDeviceArea.id'), nullable=False)
|
||||
|
||||
owner = db.relationship('User', foreign_keys=[owner_id], backref='owned_devices')
|
||||
user = db.relationship('User', foreign_keys=[user_id], backref='used_devices')
|
||||
|
||||
class nbiotDeviceStatus(db.Model):
|
||||
__tablename__ = 'nbiotDeviceStatus'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(50), nullable=False)
|
||||
description = db.Column(db.String(300), nullable=False)
|
||||
|
||||
|
||||
class nbiotDeviceType(db.Model):
|
||||
__tablename__ = 'nbiotDeviceType'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(50), nullable=False)
|
||||
description = db.Column(db.String(300), nullable=False)
|
||||
|
||||
|
||||
class nbiotDeviceArea(db.Model):
|
||||
__tablename__ = 'nbiotDeviceArea'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(50), nullable=False)
|
||||
description = db.Column(db.String(300), nullable=False)
|
||||
|
||||
|
||||
class waterDetector(db.Model):
|
||||
__tablename__ = 'waterDetector'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
pins = db.Column(db.Integer, nullable=True)
|
||||
alarms = db.Column(db.Integer, nullable=True)
|
||||
voltage = db.Column(db.Integer, nullable=True)
|
||||
signal = db.Column(db.Integer, nullable=True)
|
||||
sleepTime = db.Column(db.Integer, nullable=True)
|
||||
scanTime = db.Column(db.Integer, nullable=True)
|
||||
holdTime = db.Column(db.Integer, nullable=True)
|
||||
timeStamp = db.Column(db.DateTime, nullable=False)
|
||||
|
@ -0,0 +1,133 @@
|
||||
from flask import render_template, Blueprint, request, flash, redirect, url_for
|
||||
import iot.theme as theme
|
||||
from iot.blueprints.sensor.models import nbiotDevice
|
||||
import iot.blueprints.sensor.utils as sensorUtils
|
||||
from iot.blueprints.sensor.forms import updateNbioDeviceUpdateForm, updateNbioDeviceAddForm
|
||||
import iot.blueprints.database.utils as dbUtils
|
||||
import iot.blueprints.user.utils as userUtils
|
||||
from iot.app import db
|
||||
import json
|
||||
import os
|
||||
|
||||
sensor = Blueprint('sensor', __name__, template_folder='templates')
|
||||
|
||||
DATA_FILE = 'data.json'
|
||||
|
||||
|
||||
sensor.route('/callback', methods=['POST'])
|
||||
def callback():
|
||||
data = request.json
|
||||
|
||||
if not data:
|
||||
return jsonify({"error": "Invalid data"}), 400
|
||||
|
||||
# Read existing data
|
||||
if os.path.exists(DATA_FILE):
|
||||
with open(DATA_FILE, 'r') as f:
|
||||
stored_data = json.load(f)
|
||||
else:
|
||||
stored_data = []
|
||||
|
||||
# Append new data
|
||||
stored_data.append(data)
|
||||
|
||||
# Write data back to file
|
||||
with open(DATA_FILE, 'w') as f:
|
||||
json.dump(stored_data, f, indent=4)
|
||||
|
||||
return 'Callback received', 200
|
||||
|
||||
|
||||
@sensor.route('/data', methods=['GET'])
|
||||
def get_data():
|
||||
if os.path.exists(DATA_FILE):
|
||||
with open(DATA_FILE, 'r') as f:
|
||||
stored_data = json.load(f)
|
||||
else:
|
||||
stored_data = []
|
||||
|
||||
return jsonify(stored_data)
|
||||
|
||||
|
||||
@sensor.route('/list', methods=['GET','POST'])
|
||||
def list():
|
||||
page=request.args.get('page', 1, type=int)
|
||||
table=dbUtils.table_printable_paginate(nbiotDevice, page, 20, 'edit/', 'id')
|
||||
return(render_template('view.html', theme=theme, table=table, title="Devices List"))
|
||||
|
||||
|
||||
@sensor.route("/edit/<int:deviceId>", methods=['GET', 'POST'])
|
||||
def edit(deviceId):
|
||||
if deviceId:
|
||||
device = nbiotDevice.query.get_or_404(deviceId)
|
||||
form = updateNbioDeviceUpdateForm(current_device_id=device.id)
|
||||
form.user_id.choices = [(row.id, row.username) for row in userUtils.queryUserChoices(device.user_id)]
|
||||
form.owner_id.choices = [(row.id, row.username) for row in userUtils.queryUserChoices(device.user_id)]
|
||||
form.status_id.choices = [(row.id, row.name) for row in sensorUtils.queryStatusChoices(device.status_id)]
|
||||
form.type_id.choices = [(row.id, row.name) for row in sensorUtils.queryTypeChoices(device.type_id)]
|
||||
form.area_id.choices = [(row.id, row.name) for row in sensorUtils.queryAreaChoices(device.area_id)]
|
||||
if form.validate_on_submit():
|
||||
device.name=form.name.data
|
||||
device.device_id=form.device_id.data
|
||||
device.imsi=form.imsi.data
|
||||
device.iccid=form.iccid.data
|
||||
device.ip=form.ip.data
|
||||
device.port=form.port.data
|
||||
device.registration_date=form.registration_date.data
|
||||
device.activation_date=form.activation_date.data
|
||||
device.deactivation_date=form.deactivation_date.data
|
||||
device.owner_id=form.owner_id.data
|
||||
device.user_id=form.user_id.data
|
||||
device.status_id=form.status_id.data
|
||||
device.type_id=form.type_id.data
|
||||
device.area_id=form.area_id.data
|
||||
db.session.commit()
|
||||
flash('Device has been successfully updated', 'success')
|
||||
return redirect(url_for('sensor.edit', deviceId=deviceId))
|
||||
elif request.method == 'GET':
|
||||
form.name.data = device.name
|
||||
form.device_id.data = device.device_id
|
||||
form.imsi.data = device.imsi
|
||||
form.iccid.data = device.iccid
|
||||
form.ip.data = device.ip
|
||||
form.port.data = device.port
|
||||
form.registration_date.data = device.registration_date
|
||||
form.activation_date.data = device.activation_date
|
||||
form.deactivation_date.data = device.deactivation_date
|
||||
|
||||
return render_template('sensor/account.html',
|
||||
theme=theme,
|
||||
form=form)
|
||||
else:
|
||||
flash('You need to select a Device id', 'alarm')
|
||||
return redirect(url_for('sensor.list'))
|
||||
|
||||
|
||||
@sensor.route('/add', methods=['GET', 'POST'])
|
||||
def add():
|
||||
form = updateNbioDeviceAddForm()
|
||||
form.user_id.choices = [(row.id, row.username) for row in userUtils.queryUserChoices(1)]
|
||||
form.status_id.choices = [(row.id, row.name) for row in sensorUtils.queryStatusChoices(1)]
|
||||
form.type_id.choices = [(row.id, row.name) for row in sensorUtils.queryTypeChoices(1)]
|
||||
form.area_id.choices = [(row.id, row.name) for row in sensorUtils.queryAreaChoices(1)]
|
||||
if form.validate_on_submit():
|
||||
dev = nbiotDevice(
|
||||
name=form.name.data,
|
||||
device_id=form.device_id.data,
|
||||
imsi=form.imsi.data,
|
||||
iccid=form.iccid.data,
|
||||
ip=form.ip.data,
|
||||
port=form.port.data,
|
||||
registration_date=form.registration_date.data,
|
||||
activation_date=form.activation_date.data,
|
||||
deactivation_date=form.deactivation_date.data,
|
||||
user_id=form.user_id.data,
|
||||
status_id=form.status_id.data,
|
||||
type_id=form.type_id.data,
|
||||
area_id=form.area_id.data)
|
||||
dbUtils.dbAddAndCommit(dev)
|
||||
flash('Device has been successfully added', 'success')
|
||||
|
||||
return render_template('sensor/account.html',
|
||||
theme=theme,
|
||||
form=form)
|
@ -0,0 +1,27 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<div class="container-fluid rounded-5 mt-5 mb-5" style="{{ theme.form.div_style }};">
|
||||
<div class="row">
|
||||
<div class="col-md-3 border-right">
|
||||
<div class="d-flex flex-column align-items-center text-center p-3 py-5">
|
||||
<h2 class="account-heading" style="color: {{ theme.orange }};">{{ current_user.username }}</h2>
|
||||
<h5 class="account-heading" style="color: {{ theme.light_blue }};">{{ current_user.email_account }}</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-5 border-right">
|
||||
<div class="p-3 py-5">
|
||||
{% include 'form.html' %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 rounded">
|
||||
<div class="p-3 py-5">
|
||||
{{ info }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
@ -0,0 +1,8 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}iot{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Hompage of iot</h1>
|
||||
{{ info }}
|
||||
{% endblock %}
|
@ -0,0 +1,22 @@
|
||||
from iot.blueprints.sensor.models import nbiotDevice, nbiotDeviceStatus, nbiotDeviceType, nbiotDeviceArea
|
||||
from sqlalchemy import case
|
||||
|
||||
|
||||
|
||||
def queryById(id):
|
||||
return nbiotDevice.query.filter_by(id=id).first()
|
||||
|
||||
|
||||
def queryStatusChoices(curretnId):
|
||||
choices = nbiotDeviceStatus.query.order_by(case((nbiotDeviceStatus.id == curretnId, 0),else_=1),nbiotDeviceStatus.name.asc())
|
||||
return choices
|
||||
|
||||
|
||||
def queryTypeChoices(curretnId):
|
||||
choices = nbiotDeviceType.query.order_by(case((nbiotDeviceType.id == curretnId, 0),else_=1),nbiotDeviceType.name.asc())
|
||||
return choices
|
||||
|
||||
|
||||
def queryAreaChoices(curretnId):
|
||||
choices = nbiotDeviceArea.query.order_by(case((nbiotDeviceArea.id == curretnId, 0),else_=1),nbiotDeviceArea.name.asc())
|
||||
return choices
|
@ -0,0 +1,29 @@
|
||||
import os
|
||||
|
||||
def generate_blueprint_structure(root_dir):
|
||||
blueprint = {}
|
||||
|
||||
# Traverse the directory structure starting from the root_dir
|
||||
for root, dirs, files in os.walk(root_dir):
|
||||
# Identify the relative path to the current directory
|
||||
relative_path = os.path.relpath(root, root_dir)
|
||||
# Skip the root directory itself
|
||||
if relative_path == ".":
|
||||
continue
|
||||
# Split the relative path into its components
|
||||
path_parts = relative_path.split(os.sep)
|
||||
# Check if we're in a directory like user/templates/user/
|
||||
if len(path_parts) >= 3:
|
||||
if path_parts[0] == path_parts[2]:
|
||||
blueprint_name = path_parts[2]
|
||||
# Initialize the dictionary for the blueprint if it doesn't exist
|
||||
if blueprint_name not in blueprint:
|
||||
blueprint[blueprint_name] = {"directory": [], "html_files": []}
|
||||
blueprint[blueprint_name]["directory"].append(blueprint_name)
|
||||
|
||||
# Process files, specifically .html files, and add them to the "html_files" list
|
||||
for f in files:
|
||||
if f.endswith(".html"):
|
||||
blueprint[blueprint_name]["html_files"].append(os.path.splitext(f)[0])
|
||||
return blueprint
|
||||
|
@ -0,0 +1,15 @@
|
||||
{% if item.type == 'BooleanField' %}
|
||||
{{ item.label(class=theme.form.check_label_class, style=theme.form.check_label_style) }}
|
||||
{% endif %}
|
||||
{% if item.errors %}
|
||||
{{ item(class=theme.form.input_error_class) }}
|
||||
<div class="{{ theme.form.div_error_class }}">
|
||||
{% for error in item.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if item.type == 'BooleanField' %}
|
||||
{{ item(class=theme.form.check_class) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
@ -0,0 +1,23 @@
|
||||
{% for item in form %}
|
||||
{% if item.id == 'submit' %}
|
||||
{% elif item.id == 'csrf_token' %}
|
||||
{% else %}
|
||||
{% if item.type == 'BooleanField' %}
|
||||
<br>
|
||||
{{ item.label(class=theme.form.check_label_class, style=theme.form.check_label_style) }}
|
||||
{% endif %}
|
||||
{% if item.errors %}
|
||||
{{ item(class=theme.form.input_error_class) }}
|
||||
<div class="{{ theme.form.div_error_class }}">
|
||||
{% for error in item.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if item.type == 'BooleanField' %}
|
||||
<br>
|
||||
{{ item(class=theme.form.check_class) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
@ -0,0 +1,15 @@
|
||||
{% if item.type in ['DateField', 'DateTimeField'] %}
|
||||
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
|
||||
{% endif %}
|
||||
{% if item.errors %}
|
||||
{{ item(class=theme.form.input_error_class) }}
|
||||
<div class="{{ theme.form.div_error_class }}">
|
||||
{% for error in item.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if item.type in ['DateField', 'DateTimeField'] %}
|
||||
{{ item(class=theme.form.input_class, type=theme.form.date_type) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
@ -0,0 +1,23 @@
|
||||
{% for item in form %}
|
||||
{% if item.id == 'submit' %}
|
||||
{% elif item.id == 'csrf_token' %}
|
||||
{% else %}
|
||||
{% if item.type in ['DateField', 'DateTimeField'] %}
|
||||
<br>
|
||||
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
|
||||
{% endif %}
|
||||
{% if item.errors %}
|
||||
{{ item(class=theme.form.input_error_class) }}
|
||||
<div class="{{ theme.form.div_error_class }}">
|
||||
{% for error in item.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if item.type in ['DateField', 'DateTimeField'] %}
|
||||
<br>
|
||||
{{ item(class=theme.form.input_class, type=theme.form.date_type) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
@ -0,0 +1,6 @@
|
||||
{{ item(class=theme.form.input_error_class) }}
|
||||
<div class="{{ theme.form.div_error_class }}">
|
||||
{% for error in item.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
@ -0,0 +1,15 @@
|
||||
{% if item.type in ['IntegerField', 'DecimalField', 'FloatField'] %}
|
||||
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
|
||||
{% endif %}
|
||||
{% if item.errors %}
|
||||
{{ item(class=theme.form.input_error_class) }}
|
||||
<div class="{{ theme.form.div_error_class }}">
|
||||
{% for error in item.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if item.type in ['IntegerField', 'DecimalField', 'FloatField'] %}
|
||||
{{ item(class=theme.form.input_class) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
@ -0,0 +1,15 @@
|
||||
{% if item.type in ['SelectField'] %}
|
||||
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
|
||||
{% endif %}
|
||||
{% if item.errors %}
|
||||
{{ item(class=theme.form.input_error_class) }}
|
||||
<div class="{{ theme.form.div_error_class }}">
|
||||
{% for error in item.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if item.type in ['SelectField'] %}
|
||||
{{ item(class=theme.form.select_class, type=theme.form.select_type, style=theme.form.select_style) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
@ -0,0 +1,17 @@
|
||||
{% if item.type in ['SelectField'] %}
|
||||
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
|
||||
<br>
|
||||
{% endif %}
|
||||
{% if item.errors %}
|
||||
{{ item(class=theme.form.input_error_class) }}
|
||||
<div class="{{ theme.form.div_error_class }}">
|
||||
{% for error in item.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if item.type in ['SelectField'] %}
|
||||
{{ item(class=theme.form.select_class, type=theme.form.select_type, style=theme.form.select_style) }}
|
||||
<br>
|
||||
{% endif %}
|
||||
{% endif %}
|
@ -0,0 +1,23 @@
|
||||
{% for item in form %}
|
||||
{% if item.id == 'submit' %}
|
||||
{% elif item.id == 'csrf_token' %}
|
||||
{% else %}
|
||||
{% if item.type in ['SelectField'] %}
|
||||
<br>
|
||||
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
|
||||
{% endif %}
|
||||
{% if item.errors %}
|
||||
{{ item(class=theme.form.input_error_class) }}
|
||||
<div class="{{ theme.form.div_error_class }}">
|
||||
{% for error in item.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if item.type in ['SelectField'] %}
|
||||
<br>
|
||||
{{ item(class=theme.form.select_class, type=theme.form.select_type, style=theme.form.select_style) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
@ -0,0 +1,15 @@
|
||||
{% if item.type in ['StringField', 'TextAreaField', 'PasswordField'] %}
|
||||
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
|
||||
{% endif %}
|
||||
{% if item.errors %}
|
||||
{{ item(class=theme.form.input_error_class) }}
|
||||
<div class="{{ theme.form.div_error_class }}">
|
||||
{% for error in item.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if item.type in ['StringField', 'TextAreaField', 'PasswordField'] %}
|
||||
{{ item(class=theme.form.input_class) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
@ -0,0 +1,21 @@
|
||||
{% for item in form %}
|
||||
{% if item.id == 'submit' %}
|
||||
{% elif item.id == 'csrf_token' %}
|
||||
{% else %}
|
||||
{% if item.type in ['StringField', 'TextAreaField', 'PasswordField'] %}
|
||||
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
|
||||
{% endif %}
|
||||
{% if item.errors %}
|
||||
{{ item(class=theme.form.input_error_class) }}
|
||||
<div class="{{ theme.form.div_error_class }}">
|
||||
{% for error in item.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if item.type in ['StringField', 'TextAreaField', 'PasswordField'] %}
|
||||
{{ item(class=theme.form.input_class) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
@ -0,0 +1,5 @@
|
||||
<div class="form-groupe">
|
||||
<br>
|
||||
{{ form.submit(class=theme.form.submit_class, style=theme.form.submit_style) }}
|
||||
<br>
|
||||
</div>
|
@ -0,0 +1,34 @@
|
||||
<form method="POST" action="" enctype="multipart/form-data">
|
||||
{{ form.hidden_tag() }}
|
||||
<fieldset class="form-group">
|
||||
{% if itemList | length == 1 %}
|
||||
<div class="col-md-3 rounded">
|
||||
<div class="p-3 py-5">
|
||||
{% include 'form.html' %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
{% for labelItems in itemList %}
|
||||
<div class="col-md-3">
|
||||
<div class="p-3 py-4">
|
||||
{% for item in form %}
|
||||
{% if item.id == 'submit' %}
|
||||
{% elif item.id == 'csrf_token' %}
|
||||
{% else %}
|
||||
{% for label in labelItems %}
|
||||
{% if label == item.name %}
|
||||
{% include 'form/stringField.html' %}
|
||||
{% include 'form/selectFieldVer.html' %}
|
||||
{% include 'form/dateField.html' %}
|
||||
{% include 'form/boolField.html' %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</fieldset>
|
||||
<div>{% include 'form/submitField.html' %}</div>
|
||||
</form>
|
@ -0,0 +1,10 @@
|
||||
<form method="POST" action="" enctype="multipart/form-data">
|
||||
{{ form.hidden_tag() }}
|
||||
<fieldset class="form-group">
|
||||
<div>{% include 'form/stringFields.html' %}</div>
|
||||
<div>{% include 'form/selectFields.html' %}</div>
|
||||
<div>{% include 'form/dateFields.html' %}</div>
|
||||
<div>{% include 'form/boolFields.html' %}</div>
|
||||
</fieldset>
|
||||
<div>{% include 'form/submitField.html' %}</div>
|
||||
</form>
|
Loading…
Reference in new issue