Project view is nearly done

master
Kerem Yollu 2 years ago
parent 1fd231a1a7
commit 3e4863d0c6

@ -1,269 +0,0 @@
from minibase.database.models import Company, Company_relation, Company_legal_entity
from minibase.database.models import Industry, Countries
from minibase.database.models import Person, Person_role, Person_competence
from minibase.database.models import Project, Project_element
from minibase import db
from numpy import genfromtxt
# Gets the id of company from the formated output defined at models.py for the Company Model
# The argument formatedCompanySelection is formated by SQLAlchemy in models.py files
# Please look there before changing anything here.
def getCompanyId(formatedCompanySelection):
text = formatedCompanySelection.split(",")
return text[2] # Corresponds to the ID of the Company
# Gets the id of Person's role
def getPersonRoleId(nameForId):
selection = Person_role.query.filter_by(name=nameForId).first()
return selection.id
# Gets the id of Person's competence
def getPersonCompetenceId(nameForId):
selection = Person_competence.query.filter_by(name=nameForId).first()
return selection.id
# Gets the country of the company based on it's id
def getCompanyCountry(companyId):
selection = Company.query.filter_by(id=companyId).first()
return selection.country_bill
# Gets the state of the company based on it's id
def getCompanyState(companyId):
selection = Company.query.filter_by(id=companyId).first()
return selection.street_bill
# Gets the city of the company based on it's id
def getCompanyCity(companyId):
selection = Company.query.filter_by(id=companyId).first()
return selection.city_bill
# Gets the Postal Code of the company based on it's id
def getCompanyPostCode(companyId):
selection = Company.query.filter_by(id=companyId).first()
return selection.post_code_bill
# Gets the Name of the street of the company based on it's id
def getCompanyStreetName(companyId):
selection = Company.query.filter_by(id=companyId).first()
return selection.street_bill
# Gets the Number of the street of the company based on it's id
def getCompanyStreetNo(companyId):
selection = Company.query.filter_by(id=companyId).first()
return selection.street_no_bill
# Returns the query of all awailable companie names on the table named Company
# Note that the formating is done during the SQLAlchemy Table declaration.
def person_role_choices():
choices = Person_role.query.all()
return choices
# Returns the query of all awailable companie names on the table named Company
# Note that the formating is done during the SQLAlchemy Table declaration.
def person_competence_choices():
choices = Person_competence.query.all()
return choices
# Returns the query of all awailable companie names on the table named Company
# Note that the formating is done during the SQLAlchemy Table declaration.
def company_choices():
choices = Company.query.all()
return choices
# Retunrs the qurry of all awailable industrie names on the table named Industry
# Note that the formating is done during the SQLAlchemy Table declaration.
def company_industry_choices():
choices = Industry.query.all()
return choices
# Retunrs the query of all awailable legal entity names on the table named Company_legal_entity
# Note that the formating is done during the SQLAlchemy Table declaration.
def company_legal_entity_choices():
choices = Company_legal_entity.query.all()
return choices
# Retunrs the query of all awailable Relation names on the table named Company_relation
# Note that the formating is done during the SQLAlchemy Table declaration.
def company_relation_choices():
choices = Company_relation.query.all()
return choices
# The Company Model has Industry Column as a foreign key and it requires the Industry's ID
# And not the name. so this function returns the right ID of the name shown at the
# Register Company Form
def getIndustryId(nameForId):
selection = Industry.query.filter_by(name=nameForId).first() # Gets the id of Role
return selection.id
# The Company Model has Relation Column as a foreign key and it requires the Industry's ID
# And not the name. so this function returns the right ID of the name shown at the
# Register Company Form
def getRelationId(nameForId):
selection = Company_relation.query.filter_by(name=nameForId).first() # Gets the id of Role
return selection.id
# The Company Model has Legal Entity Column as a foreign key and it requires the Industry's ID
# And not the name. so this function returns the right ID of the name shown at the
# Register Company Form
def getLegalEntityId(nameForId):
selection = Company_legal_entity.query.filter_by(name=nameForId).first() # Gets the id of Role
return selection.id
# Retunrs the query of all awailable Country names on the table named Countries
# Note that the formating is done during the SQLAlchemy Table declaration.
# Important note This table is ImporteD externally from a modifier SQL version of
# Github : https://github.com/dr5hn/countries-states-cities-database
def country_choices():
choices = Countries.query.all()
return choices
###################################################################################################
# CSV manipulation
###################################################################################################
def openCsv(filename):
data = genfromtxt(filename,
delimiter=',',
skip_header=1,
dtype=None,
encoding='UTF-8')
return data.tolist()
def db_add_name_and_description(csv, table):
try:
csv_list = openCsv(csv)
for i in csv_list:
record = table(**{
'name': i[0],
'description': i[1]})
db.session.add(record) # Add all the records
db.session.commit() # Attempt to commit all the records
except:
db.session.rollback() # Rollback the changes on error
print("Error Ocured during <<NAME AND DESCRIPTION>> upload to DB")
def db_add_company(csv):
try:
csv_list = openCsv(csv)
for i in csv_list:
record = Company(**{
'name': i[0],
'legal_entity_id': i[1],
'relation_id': i[2],
'industry_id': i[3],
'status_id': i[4],
'website': i[5],
'street_bill': i[6],
'street_no_bill': i[7],
'city_bill': i[8],
'post_code_bill': i[9],
'state_bill': i[10],
'country_bill': i[11],
'street_ship': i[12],
'street_no_ship': i[13],
'city_ship': i[14],
'post_code_ship': i[15],
'state_ship': i[16],
'country_ship': i[17]})
db.session.add(record) # Add all the records
db.session.commit() # Attempt to commit all the records
except Exception as error:
db.session.rollback() # Rollback the changes on error
print("Error Ocured during <<COMPANY>> upload to DB")
print(error)
def db_add_person(csv):
try:
csv_list = openCsv(csv)
print(csv_list)
for i in csv_list:
record = Person(**{
'name': i[0],
'last_name': i[1],
'company_id': i[2],
'role_id': i[3],
'competence_id': i[4],
'mail_prof': i[5],
'mail_priv': i[6],
'tel_prof_mobile': i[7],
'street_name': i[8],
'street_no': i[9],
'city': i[10],
'post_code': i[11],
'state': i[12],
'country': i[13]
})
db.session.add(record) # Add all the records
db.session.commit() # Attempt to commit all the records
except Exception as error:
db.session.rollback() # Rollback the changes on error
print("Error Ocured during <<PERSON>> upload to DB")
print(error)
def db_add_project(csv):
try:
csv_list = openCsv(csv)
print(csv_list)
for i in csv_list:
record = Project(**{
'name': i[0],
'description': i[1],
'company_id': i[2],
'status_id': i[3],
'industry_id': i[4],
'owner_id': i[5],
'qte_prototype': i[6],
'qte_start': i[7],
'qte_production': i[8],
})
db.session.add(record) # Add all the records
db.session.commit() # Attempt to commit all the records
except Exception as error:
db.session.rollback() # Rollback the changes on error
print(csv)
print("Error Ocured during <<PROJECT>> upload to DB")
print(error)
def db_add_project_element(csv):
try:
csv_list = openCsv(csv)
print(csv_list)
for i in csv_list:
record = Project_element(**{
'name': i[0],
'description': i[1],
'qte_per_project': i[2],
'project_id': i[3],
'owner_id': i[4],
'status_id': i[5],
})
db.session.add(record) # Add all the records
db.session.commit() # Attempt to commit all the records
except Exception as error:
db.session.rollback() # Rollback the changes on error
print(csv)
print("Error Ocured during <<PROJECT ELEMENT>> upload to DB")
print(error)

Binary file not shown.

@ -1,6 +1,7 @@
from flask import Flask
from flask_session import Session
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.declarative import declarative_base
from flask_bcrypt import Bcrypt
from flask_login import LoginManager
from flask_mail import Mail
@ -16,6 +17,7 @@ login_manager.login_view = 'users.login'
login_manager.login_message_category = 'info' # Boostrap Info Message
# (EMAIL AGENT) Definition
mail = Mail()
session = Session()
def create_minibase(config_class=Config):
@ -31,14 +33,16 @@ def create_minibase(config_class=Config):
login_manager.init_app(app)
# (EMAIL AGENT) Initialisation
mail.init_app(app)
# (FLASK) Importing and then registering Blueprints (Wievs)
# Session for variable manipulation on server side
# (FLASK) Importing and then registering Blueprints (Wievs)
from minibase.users.routes import users
from minibase.posts.routes import posts
from minibase.main.routes import main
from minibase.company.routes import company
from minibase.admin.routes import admin
from minibase.person.routes import person
from minibase.project.routes import project
from minibase.errors.handlers import errors
app.register_blueprint(users)
app.register_blueprint(posts)
@ -46,6 +50,7 @@ def create_minibase(config_class=Config):
app.register_blueprint(company)
app.register_blueprint(admin)
app.register_blueprint(person)
app.register_blueprint(project)
app.register_blueprint(errors)
# Returnr The created app
# Return The created app
return app

@ -1,6 +1,6 @@
def doesNameExistsCi(table, name):
exists = table.query.filter(table.name.ilike(name.data)).first() # Database Querry ilike means case insessitive
exists = table.query.filter(table.name.ilike(name)).first() # Database Querry ilike means case insessitive
if exists:
return 1
return 0

@ -2,23 +2,23 @@ from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, IntegerField, SelectField
from wtforms.validators import DataRequired, Length, ValidationError, Optional
from minibase.database.models import Company
import minibase.database.utils as DbUtils
import minibase.database.utils as dbUtils
# Defines the form class to be used for the user registretion
class companyForm(FlaskForm):
# Decalarion of the fields for the form and it's propereties
company_name = StringField('Name', validators=[DataRequired(), Length(min=3, max=20)])
legal_entity_id = SelectField('Legal Entity', choices=DbUtils.company_legal_entity_choices, validators=[DataRequired()])
relation_id = SelectField('Relation', choices=DbUtils.company_relation_choices, validators=[DataRequired()])
legal_entity_id = SelectField('Legal Entity', choices=dbUtils.company_legal_entity_choices, validators=[DataRequired()])
relation_id = SelectField('Relation', choices=dbUtils.company_relation_choices, validators=[DataRequired()])
website = StringField('Website', validators=[Optional(), Length(min=3, max=100)])
country = SelectField('Country', choices=DbUtils.country_choices,validators=[DataRequired()])
country = SelectField('Country', choices=dbUtils.getCountryNames,validators=[DataRequired()])
state = StringField('State', validators=[DataRequired()])
city = StringField('City', validators=[DataRequired()])
post = IntegerField('Zip', validators=[DataRequired()])
street = StringField('Street', validators=[DataRequired()])
no = IntegerField('No', validators=[DataRequired()])
industry_id = SelectField('Area', choices=DbUtils.company_industry_choices, validators=[DataRequired()])
industry_id = SelectField('Area', choices=dbUtils.getIndustryNames, validators=[DataRequired()])
submit = SubmitField('Register Company')
# Queries to be made in order to validate the form : If Company name exitst within the same country

@ -0,0 +1 @@
,key,devbian,20.10.2023 11:27,file:///home/key/.config/libreoffice/4;

@ -1,4 +1,4 @@
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
from itsdangerous import URLSafeTimedSerializer as Serializer
from datetime import datetime
from minibase import db, login_manager
from flask_login import UserMixin
@ -49,7 +49,6 @@ class Post(db.Model):
def __repr__(self):
return f"User('{self.title}', '{self.date_posted}')"
###################################################################################################
# ADMIN
###################################################################################################
@ -107,6 +106,7 @@ class Note_status(db.Model):
last_update_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
company_notes = db.relationship('Company_note', backref='company_note_status', lazy=True)
person_notes = db.relationship('Person_note', backref='person_note_status', lazy=True)
project_notes = db.relationship('Project_note', backref='project_note_status', lazy=True)
# returns a more information-rich, or official, string representation of an object
def __repr__(self):
@ -172,8 +172,11 @@ class Person(db.Model):
# One To Many relationships for a company having mutliple elements of the following indexes
# Example : One company would/could have many eployees
notes = db.relationship('Person_note', backref='person', lazy=True)
projects = db.relationship('Project', backref='project_responsible', lazy=True)
elements = db.relationship('Project', backref='element_responsible', lazy=True)
projects = db.relationship('Project', backref='project_responsible', lazy=True, viewonly=True)
elements = db.relationship('Project', backref='element_responsible', lazy=True, viewonly=True)
def __repr__(self):
return f"{self.name} {' '} {self.last_name}"
class Person_role(db.Model):
@ -299,7 +302,8 @@ class Company_note(db.Model):
# returns a more information-rich, or official, string representation of an object
def __repr__(self):
return f"{self.title}, {self.status}, {self.content}"
return f"{self.title}, {self.content}"
###################################################################################################
# Project
@ -316,8 +320,9 @@ class Project(db.Model):
qte_production = db.Column(db.Integer, nullable=False)
upload_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
last_update_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
image_file = db.Column(db.String(30), nullable=False, default='default_project.jpg')
# One To Many relationships where indexes can point o mutiple companies.
# One To Many relationships where indexes can point o mutiple compani30.
company_id = db.Column(db.Integer, db.ForeignKey('company.id'), nullable=False)
status_id = db.Column(db.Integer, db.ForeignKey('project_status.id'), nullable=False)
industry_id = db.Column(db.Integer, db.ForeignKey('industry.id'), nullable=False)
@ -326,6 +331,7 @@ class Project(db.Model):
# One To Many relationships for a company having mutliple elements of the following indexes
# Example : One company would/could have many eployees
elements = db.relationship('Project_element', backref='project', lazy=True)
notes = db.relationship('Project_note', backref='project', lazy=True)
# returns a more information-rich, or official, string representation of an object
def __repr__(self):
@ -354,13 +360,29 @@ class Project_status(db.Model):
upload_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
last_update_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
projects = db.relationship('Project', backref='status', lazy=True)
elements = db.relationship('Project', backref='element_status', lazy=True)
projects = db.relationship('Project', backref='status', lazy=True, viewonly=True)
elements = db.relationship('Project', backref='element_status', lazy=True, viewonly=True)
# returns a more information-rich, or official, string representation of an object
def __repr__(self):
return f"{self.name}"
class Project_note(db.Model):
id = db.Column(db.Integer, primary_key=True)
priority = db.Column(db.Integer, nullable=False, default='0')
title = db.Column(db.String(100), nullable=False)
content = db.Column(db.Text, nullable=False)
date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
date_due = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
project_id = db.Column(db.Integer, db.ForeignKey('project.id'), nullable=False)
status_id = db.Column(db.Integer, db.ForeignKey('note_status.id'), nullable=False)
# returns a more information-rich, or official, string representation of an object
def __repr__(self):
return f"{self.title}, {self.content}"
###################################################################################################
# Product
###################################################################################################

@ -1,3 +1,5 @@
name,last_name,company_id,role_id,competence_id,mail_prof,mail_priv,tel_prof_mobile,street_name,street_no,city,post_code,state,country
Kerem,Yollu,2,3,1,kerem.yollu_at_kynsight.com,kerem.yollu@gmail.com,41789716697,Meierackerstrasse,10,Uster,8610,Zürich,Switzerland
Stefan,Walker,1,2,2,stefan.walker_at_steinel.ch,stefan.walker@gmail.com,41789716697,Almeinderstrasse,10,Einsiedeln,8410,Schwyz,Switzerland
Kerem,Yollu,2,3,1,kerem.yollu@kynsight.com,kerem.yollu@gmail.com,41789716697,Meierackerstrasse,10,Uster,8610,Zürich,Switzerland
Stefan,Walker,1,2,2,stefan.walker@steinel.ch,stefan.walker@gmail.com,41789716697,Almeinderstrasse,10,Einsiedeln,8410,Schwyz,Switzerland
Meier,Müller,1,2,2,meier.mueller@steinel.ch,meier.mueller@steinel.ch,41789716697,Almeinderstrasse,10,Einsiedeln,8410,Schwyz,Switzerland
Suleyman,Siksok,1,2,2,suleyman.siksok@steinel.ch,suleyman.siksok@steinel.ch,41789716697,Almeinderstrasse,10,Einsiedeln,8410,Schwyz,Switzerland

1 name last_name company_id role_id competence_id mail_prof mail_priv tel_prof_mobile street_name street_no city post_code state country
2 Kerem Yollu 2 3 1 kerem.yollu_at_kynsight.com kerem.yollu@kynsight.com kerem.yollu@gmail.com 41789716697 Meierackerstrasse 10 Uster 8610 Zürich Switzerland
3 Stefan Walker 1 2 2 stefan.walker_at_steinel.ch stefan.walker@steinel.ch stefan.walker@gmail.com 41789716697 Almeinderstrasse 10 Einsiedeln 8410 Schwyz Switzerland
4 Meier Müller 1 2 2 meier.mueller@steinel.ch meier.mueller@steinel.ch 41789716697 Almeinderstrasse 10 Einsiedeln 8410 Schwyz Switzerland
5 Suleyman Siksok 1 2 2 suleyman.siksok@steinel.ch suleyman.siksok@steinel.ch 41789716697 Almeinderstrasse 10 Einsiedeln 8410 Schwyz Switzerland

@ -1,10 +1,13 @@
from minibase.database.models import Company, Company_relation, Company_legal_entity
from minibase.database.models import Industry, Countries
from minibase.database.models import Person, Person_role, Person_competence
from minibase.database.models import Project, Project_element, Product
from minibase.database.models import Project, Project_element, Project_status, Project_note
from minibase.database.models import Product
from minibase import db
from numpy import genfromtxt
selectedCompany=0
selectedProject=0
# Gets the id of company from the formated output defined at models.py for the Company Model
# The argument formatedCompanySelection is formated by SQLAlchemy in models.py files
@ -26,6 +29,12 @@ def getPersonCompetenceId(nameForId):
return selection.id
# Gets the name based on Person's id
def getPersonName(personId):
selection = Person.query.filter_by(id=personId).first()
return selection
# Gets the country of the company based on it's id
def getCompanyCountry(companyId):
selection = Company.query.filter_by(id=companyId).first()
@ -62,7 +71,108 @@ def getCompanyStreetNo(companyId):
return selection.street_no_bill
# Returns the query of all awailable companie names on the table named Company
# Gets the names the all the companies
def getCompanyNames():
selection = Company.query.order_by(Company.name.asc())
return selection
# Gets the Name of the street of the company based on it's id
def getCompanyName(companyId):
selection = Company.query.filter_by(id=companyId).first()
return selection.name
####################################################################################################
# Gets the Project class of based on it's id
def getProject(projectId):
selection = Project.query.filter_by(id=projectId).first()
return selection
# Gets the names the all the projects
def getProjectNames():
selection = Project.query.order_by(Project.name.asc())
return selection
# Gets the awailable Statuses of all the projects
def getProjectStatuses():
selection = Project_status.query.order_by(Project_status.name.asc())
return selection
# Gets the Name of the street of the company based on it's id
def getProjectName(projectId):
selection = Project.query.filter_by(id=projectId).first()
return selection.name
# Defines the selected company for the current request. This is important to fill so that some
# Templates knows if they have to show something and warns the user if no compani was selected
def setSelectedCompany(company_id):
global selectedCompany
selectedCompany = int(company_id)
# Returns the Selected company
def getSelectedCompany():
global selectedCompany
return selectedCompany
# Get the list of projects for the selected Company and if no company was selected
# Prints an error that will be put in the selection form.
def getProjectOfSelectedCompany():
global selectedCompany
if selectedCompany:
selection = Project.query.filter_by(company_id=selectedCompany)
return selection
return ["No company is selected"]
# Get the list of projects for the selected Company and if no company was selected
# Prints an error that will be put in the selection form.
def getEmployeesOfSelectedCompany():
global selectedCompany
if selectedCompany:
selection = Person.query.filter_by(company_id=selectedCompany)
return selection
return ["No company is selected"]
# Defines the selected project for the current request. This is important to fill so that some
# Templates knows if they have to show something and warns the user if no compani was selected
def setSelectedProject(project_id):
global selectedProject
selectedProject = int(project_id)
# Returns the Selected project
def getSelectedProject():
return selectedProject
def getSelectedProjectOwner():
global selectedProject
if selectedProject:
selection = Project.query.filter_by(id=selectedProject).first()
return getPersonName(selection.project_responsible.id)
return ["No Project is selected"]
def getSelectedProjectNotes():
global selectedProject
if selectedProject:
selection = Project_note.query.filter_by(project_id=selectedProject)
return selection
return ["No Project is selected"]
# Get the project id based on the project's name and compan's id
# As they can be project's that have the same name but corresponds to different companies.
def getProjectId(companyId, projectName):
global selectedCompany
selection = Project.query.filter_by(company_id=companyId, name=projectName).first()
return selection.id
# Returns the query of all awailable companie names on the table named Project
# Note that the formating is done during the SQLAlchemy Table declaration.
def person_role_choices():
choices = Person_role.query.all()
@ -76,16 +186,9 @@ def person_competence_choices():
return choices
# Returns the query of all awailable companie names on the table named Company
# Note that the formating is done during the SQLAlchemy Table declaration.
def company_choices():
choices = Company.query.all()
return choices
# Retunrs the qurry of all awailable industrie names on the table named Industry
# Note that the formating is done during the SQLAlchemy Table declaration.
def company_industry_choices():
def getIndustryNames():
choices = Industry.query.all()
return choices
@ -132,10 +235,11 @@ def getLegalEntityId(nameForId):
# Note that the formating is done during the SQLAlchemy Table declaration.
# Important note This table is ImporteD externally from a modifier SQL version of
# Github : https://github.com/dr5hn/countries-states-cities-database
def country_choices():
def getCountryNames():
choices = Countries.query.all()
return choices
###################################################################################################
# CSV manipulation
###################################################################################################

@ -2,7 +2,7 @@ from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, SelectField, DateField
from wtforms.validators import DataRequired, Length, ValidationError, Email, Optional
from minibase.database.models import Person
import minibase.database.utils as DbUtils
import minibase.database.utils as dbUtils
# Defines the form class to be used for the user registretion
@ -17,9 +17,9 @@ class personForm(FlaskForm):
tel_prof_mobile = StringField('Tel Professional Mob', validators=[Optional()])
tel_priv_fix = StringField('Tel Private Fix', validators=[Optional()])
tel_priv_mobile = StringField('Tel Private Mob', validators=[Optional()])
company_id = SelectField('Company', choices=DbUtils.company_choices, validators=[DataRequired()])
competence_id = SelectField('Competence', choices=DbUtils.person_competence_choices, validators=[DataRequired()])
role_id = SelectField('Role', choices=DbUtils.person_role_choices, validators=[DataRequired()])
company_id = SelectField('Company', choices=dbUtils.getCompanyNames, validators=[DataRequired()])
competence_id = SelectField('Competence', choices=dbUtils.person_competence_choices, validators=[DataRequired()])
role_id = SelectField('Role', choices=dbUtils.person_role_choices, validators=[DataRequired()])
submit = SubmitField('Register Person')
# Queries to be made in order to validate the form : If person with this name exitst within the same company

@ -0,0 +1,48 @@
from flask_wtf import FlaskForm
from wtforms import SubmitField, SelectField, DateField, IntegerField, StringField
from wtforms.validators import DataRequired, Length, ValidationError
from flask_wtf.file import FileField, FileAllowed
import minibase.database.utils as dbUtils
class getCompanyNameForm(FlaskForm): # Defines the form class to be used for the user registretion
# Decalarion of the fields for the form and it's propereties
company = SelectField('Company Name', choices=dbUtils.getCompanyNames, validators=[DataRequired()])
submit = SubmitField('Show Projects')
class getProjectNameForm(FlaskForm): # Defines the form class to be used for the user registretion
# Decalarion of the fields for the form and it's propereties
project = SelectField('Project Name', choices=dbUtils.getProjectOfSelectedCompany, validators=[DataRequired()])
submit = SubmitField('Show Project details')
class projectRegisterForm(FlaskForm):
name = StringField('ProjectName', validators=[DataRequired(), Length(min=3, max=20)])
description = StringField('ProjectName', validators=[DataRequired(), Length(min=3, max=300)])
qtePrototype = IntegerField('Prototye Quantity', validators=[DataRequired()])
datePrototye = DateField('Prototyping Date', validators=[DataRequired()])
qteStart = IntegerField('Starting Quantity', validators=[DataRequired()])
dateStart = DateField('Firts Starting Date', validators=[DataRequired()])
qteStartProduction = IntegerField('Production Quantity', validators=[DataRequired()])
dateProduction = DateField('Production Date', validators=[DataRequired()])
company = SelectField('Company name', choices=dbUtils.getCompanyNames, validators=[DataRequired()])
industry = SelectField('industry', choices=dbUtils.getIndustryNames, validators=[DataRequired()])
picture = FileField('Update Profile Picture', validators=[FileAllowed(['jpg', 'png'])])
submit = SubmitField('Register Project')
class projectUpdateForm(FlaskForm):
description = StringField('Description', validators=[DataRequired(), Length(min=3, max=300)])
industry = SelectField('industry', validators=[DataRequired()])
status = SelectField('Status', validators=[DataRequired()])
responsible = SelectField('Repsonsible', validators=[DataRequired()])
qtePrototype = IntegerField('Prototye Quantity', validators=[DataRequired()])
datePrototype = DateField('Prototyping Date', validators=[DataRequired()])
qteStart = IntegerField('Starting Quantity', validators=[DataRequired()])
dateStart = DateField('Starting Date', validators=[DataRequired()])
qteProduction = IntegerField('Production Quantity', validators=[DataRequired()])
dateProduction = DateField('Production Date', validators=[DataRequired()])
picture = FileField('Picture', validators=[FileAllowed(['jpg', 'png'])])
submit = SubmitField('Update Project')

@ -1,37 +1,97 @@
from flask import render_template, url_for, flash, redirect, request, Blueprint
from flask import render_template, url_for, flash, redirect, request, Blueprint, session
from minibase import db
from minibase.config import themeMinibase
from minibase.database.models import Company, Company_legal_entity, Company_relation,Company_status
from minibase.database.models import Industry, Note_status
from minibase.database.models import Person_role, Person_competence
from minibase.database.models import Project_status
from minibase.admin.forms import compLegalEntityForm, compRelationForm, industryRegisterForm,personRoleForm, personCompetenceForm, compStatusForm, noteStatusForm
from minibase.admin.forms import projectStatusForm
from minibase.project.forms import getProjectNameForm, getCompanyNameForm, projectUpdateForm
import minibase.database.utils as dbUtils
from minibase.database.models import Project, Company
# Declaring a blueprint
project = Blueprint('project', __name__)
@admin.route("/register", methods=['GET', 'POST'])
def register():
form = register()
legal_entities = Company_legal_entity.query.order_by(Company_legal_entity.name.asc())
@project.route("/select_company", methods=['GET', 'POST'])
def select_company():
form = getCompanyNameForm()
if form.validate_on_submit():
companyLegal = Company_legal_entity(
name=form.name.data,
description=form.description.data)
# Here we need to give the id of thr role as this is a foreign key
db.session.add(companyLegal)
db.session.commit()
companyId = dbUtils.getCompanyId(form.company.data)
dbUtils.setSelectedCompany(companyId)
return redirect(url_for('project.select_project'))
return render_template('project/select_company.html',
title='Select Company Name',
theme=themeMinibase,
form=form)
@project.route("/select_project", methods=['GET', 'POST'])
def select_project():
if dbUtils.getSelectedCompany(): # If a company is lesected
form = getProjectNameForm()
companyId = dbUtils.getSelectedCompany()
company_selected = dbUtils.getCompanyName(companyId)
if form.validate_on_submit():
flash(f'{"Project Loaded"}', 'success')
projectId = dbUtils.getProjectId(companyId, form.project.data)
dbUtils.setSelectedProject(projectId)
return redirect(url_for('project.show_project'))
flash(f'{"Company Legal Entity registered!"}', 'success')
return render_template('admin/company_register_legal_entity.html',
title='Register Company Legal Entity',
legal_entities=legal_entities,
return render_template('project/select_project.html',
title='Select Project Name for : ' + company_selected,
theme=themeMinibase,
form=form)
else:
return redirect(url_for('project.select_company'))
@project.route("/show_project", methods=['GET', 'POST'])
def show_project():
if dbUtils.getSelectedProject(): # If a project is lesected
form = projectUpdateForm()
projectId = dbUtils.getSelectedProject()
project = dbUtils.getProject(projectId)
image_file = url_for('static', filename='pics/' + project.image_file)
notes = dbUtils.getSelectedProjectNotes()
# To initiate choises as a list allow us to match it with the id's
form.responsible.choices = [(row.id, row.name +' '+row.last_name) for row in dbUtils.getEmployeesOfSelectedCompany()]
form.status.choices = [(row.id, row.name) for row in dbUtils.getProjectStatuses()]
form.industry.choices = [(row.id, row.name) for row in dbUtils.getIndustryNames()]
if form.validate_on_submit():
flash(f'{"Project Updated"}', 'success')
project.owner_id = int(form.responsible.data)
project.status_id = int(form.status.data)
project.description = form.description.data
project.qte_prototype = form.qtePrototype.data
project.qte_start = form.qteStart.data
project.qte_production = form.qteProduction.data
project.date_prototype = form.datePrototype.data
project.date_start = form.dateStart.data
project.date_production = form.dateProduction.data
db.session.add(project)
db.session.commit()
return redirect(url_for('project.show_project'))
elif request.method == 'GET':
form.responsible.data = str(project.owner_id)
form.status.data = str(project.status.id)
form.industry.data = str(project.industry_id)
form.description.data = project.description
form.qtePrototype.data = project.qte_prototype
form.qteStart.data = project.qte_start
form.qteProduction.data = project.qte_production
form.datePrototype.data = project.date_prototype
form.dateStart.data = project.date_start
form.dateProduction.data = project.date_production
return render_template('admin/company_register_legal_entity.html',
title='Register Company Legal Entity',
legal_entities=legal_entities,
return render_template('project/show_project.html',
#title=project.belongs_to.name + ' : ' + project.name,
title="kerem",
companyName=project.belongs_to.name,
projectName=project.name,
projectId=project.id,
notes=notes,
image_file=image_file,
theme=themeMinibase,
form=form)
else:
return redirect(url_for('project.select_project'))

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en-eu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
@ -69,8 +69,17 @@
<a class="dropdown-item" href="#">Database</a>
</div>
<li class="nav-item"><a class="nav-link" href="{{ url_for('main.customer') }}">Custommer</a></li>
<li class="nav-item"><a class="nav-link" href="#">Projects</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Project</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ url_for('project.select_company') }}">Find Projects</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Register Project</a>
<a class="dropdown-item" href="#">Update Project</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Register Element</a>
<a class="dropdown-item" href="#">Update Element</a>
</div>
{% endif %}
</ul>
<ul class="navbar-nav ml-auto">

@ -0,0 +1,30 @@
{% extends "layout.html" %}
{% block content %}
<div class="{{ theme.userInputDivClass }}" style="{{ theme.userInputFormColor }}">
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
<legend class="border-bottom mb-4">{{ title }}</legend>
<!-- Country of the company -->
<div class="form-group">
{{ form.company.label(class="form-control-label") }}
{% if form.company.errors %}
{{ form.company(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.company.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.company(class="form-control form-control-lg") }}
{% endif %}
</div>
</fieldset>
<!-- Submit Button -->
<div class="form-group">
{{ form.submit(class="btn btn-outline-info") }}
</div>
</form>
</div>
{% endblock content %}

@ -0,0 +1,31 @@
{% extends "layout.html" %}
{% block content %}
<div class="{{ theme.userInputDivClass }}" style="{{ theme.userInputFormColor }}">
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
<legend class="border-bottom mb-4">{{ title }}</legend>
<!-- Country of the project -->
<div class="form-group">
{{ form.project.label(class="form-control-label") }}
{% if form.project.errors %}
{{ form.project(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.project.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.project(class="form-control form-control-lg") }}
{% endif %}
</div>
</fieldset>
<!-- Submit Button -->
<div class="form-group">
{{ form.submit(class="btn btn-outline-info") }}
<a type="button" class="btn btn-secondary" href="{{ url_for('project.select_company') }}">Back to company selection</a>
</div>
</form>
</div>
{% endblock content %}

@ -0,0 +1,209 @@
{% extends "layout.html" %}
{% block content %}
<div class="container-fluid" style="{{ theme.userInputFormColor }}">
<div class="container py-2">
<div class="row">
<div class="col-lg-4">
<div class="card mb-4">
<div class="card-body text-center">
<h4 class="card-title">{{ projectName }}</h4>
<h6 class="card-subtitle mb-2 text-muted">ID: {{ projectId }}</h6>
<img src={{ image_file }} alt="avatar" class="rounded-circle img-fluid" style="width: 150px;">
</div>
</div>
<div class="card mb-4 mb-lg-0">
<div class="card-body p-0">
<ul class="list-group list-group-flush rounded-3">
{% for note in notes %}
<div class="card">
<div class="card-body">
<h5 class="card-title"> <a href="#">{{ note.title }} |{{ note.project_note_status }}| </a> </h5>
<h6 class="card-subtitle mb-2 text-muted">Posted: {{ note.date_posted.strftime('%d-%m-%Y') }} | Due: {{ note.date_due.strftime('%d-%m-%Y')}}</h6>
<p class="card-text">{{ note.content }}</p>
</div>
</div>
{% endfor %}
</ul>
</div>
</div>
</div>
<div class="col-lg-8">
<div class="card mb-4">
<form class="card-body" method="POST" action="">
{{ form.hidden_tag() }}
<div class="form-goup row">
<div class="col-sm-2">
Name
</div>
<div class="col">
{{ projectName }}
</div>
</div>
<div class="form-goup row">
{{ form.description.label(class="col-sm-2 col-form-label") }}
<div class="col-sm-10">
{% if form.description.errors %}
{{ form.description( class="form-control is-invalid") }}
<div class="invalid-feedback">
{% for error in form.description.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.description( class="form-control") }}
{% endif %}
</div>
</div>
<div class="form-goup row">
{{ form.industry.label(class="col-sm-2 col-form-label") }}
<div class="col-sm-10">
{% if form.industry.errors %}
{{ form.industry( class="form-control is-invalid") }}
<div class="invalid-feedback">
{% for error in form.industry.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.industry( class="form-control") }}
{% endif %}
</div>
</div>
<div class="form-goup row">
{{ form.status.label(class="col-sm-2 col-form-label") }}
<div class="col-sm-10">
{% if form.status.errors %}
{{ form.status( class="form-control is-invalid") }}
<div class="invalid-feedback">
{% for error in form.status.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.status( class="form-control") }}
{% endif %}
</div>
</div>
<hr>
<div class="form-goup row">
{{ form.responsible.label(class="col-sm-2 col-form-label") }}
<div class="col-sm-10">
{% if form.responsible.errors %}
{{ form.responsible( class="form-control is-invalid") }}
<div class="invalid-feedback">
{% for error in form.responsible.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.responsible( class="form-control") }}
{% endif %}
</div>
</div>
<hr>
<div class="form-goup row text-center">
<div class="col">
{{ form.qtePrototype.label(class="col-form-label") }}
<div class="col">
{% if form.qtePrototype.errors %}
{{ form.qtePrototype( class="form-control is-invalid") }}
<div class="invalid-feedback">
{% for error in form.qtePrototype.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.qtePrototype( class="form-control") }}
{% endif %}
</div>
</div>
<div class="col">
{{ form.qteStart.label(class="col-form-label") }}
<div class="col">
{% if form.qteStart.errors %}
{{ form.qteStart( class="form-control is-invalid") }}
<div class="invalid-feedback">
{% for error in form.qteStart.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.qteStart( class="form-control") }}
{% endif %}
</div>
</div>
<div class="col">
{{ form.qteProduction.label(class="col-form-label") }}
<div class="col">
{% if form.qteProduction.errors %}
{{ form.qteProduction( class="form-control is-invalid") }}
<div class="invalid-feedback">
{% for error in form.qteProduction.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.qteProduction( class="form-control") }}
{% endif %}
</div>
</div>
</div>
<div class="form-goup row text-center">
<div class="col">
{{ form.datePrototype.label(class="col-form-label") }}
<div class="col">
{% if form.datePrototype.errors %}
{{ form.datePrototype( class="form-control is-invalid") }}
<div class="invalid-feedback">
{% for error in form.datePrototype.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.datePrototype( class="form-control") }}
{% endif %}
</div>
</div>
<div class="col">
{{ form.dateStart.label(class="col-form-label") }}
<div class="col">
{% if form.dateStart.errors %}
{{ form.dateStart( class="form-control is-invalid") }}
<div class="invalid-feedback">
{% for error in form.dateStart.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.dateStart( class="form-control") }}
{% endif %}
</div>
</div>
<div class="col">
{{ form.dateProduction.label(class="col-form-label") }}
<div class="col">
{% if form.dateProduction.errors %}
{{ form.dateProduction( class="form-control is-invalid") }}
<div class="invalid-feedback">
{% for error in form.dateProduction.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.dateProduction( class="form-control") }}
{% endif %}
</div>
</div>
</div>
<hr>
<div class="form-group">
{{ form.submit(class="btn btn-outline-info") }}
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock content %}

@ -1,16 +1,17 @@
from minibase import db, create_minibase
import minibase.database.utils as dbUtils
from minibase.database.models import Person, Person_role, Person_competence, Person_note
from minibase.database.models import Person, Person_role, Person_competence, Person_note
from minibase.database.models import Company, Company_relation, Company_legal_entity, Company_note, Company_status
from minibase.database.models import Status, Industry, Note_status
from minibase.database.models import Project, Project_status, Project_element
from minibase.database.models import Project, Project_status, Project_element, Project_note
from minibase.database.models import Product, Product_status, Product_physical, Product_packaging, Product_domain, Product_eligibility, Product_category, Product_sub_category, Product_classification
app = create_minibase()
app.app_context().push()
db.drop_all()
db.create_all()
status = db.drop_all()
status = db.create_all()
###################################################################################################
@ -93,6 +94,29 @@ dbUtils.db_add_project("minibase/database/project.csv")
dbUtils.db_add_project_element("minibase/database/project_element.csv")
note6 = Project_note(
title='STWAHAving issues to get the RFID chip',
content='STM doesn t want to deliver the chip throug distribution channel',
priority='10',
project_id='1',
status_id='1')
db.session.add(note6)
note7 = Project_note(
title='STM whants to go to steinerl directly',
content='Italian part of STM is willin gto to directly to Steinel and they are not interested on letting us get the lead',
priority='10',
project_id='1',
status_id='1')
db.session.add(note7)
note8 = Project_note(
title='Ilker Is speeling',
content='Ilker is tocupied too much wiht the shisha bar an letting our project fall',
priority='5',
project_id='2',
status_id='2')
db.session.add(note8)
###################################################################################################
dbUtils.db_add_name_and_description("minibase/database/product_category.csv", Product_category)
dbUtils.db_add_name_and_description("minibase/database/product_classification.csv", Product_classification)

@ -0,0 +1,20 @@
bcrypt==4.0.1
blinker==1.6.2
click==8.1.7
dnspython==2.4.2
email-validator==2.0.0.post2
Flask-Session==0.4.1
Flask==2.2.5
Flask-Bcrypt==1.0.1
Flask-Login==0.6.2
Flask-SQLAlchemy==3.1.1
Flask-WTF==1.2.1
greenlet==2.0.2
idna==3.4
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.3
SQLAlchemy==2.0.21
typing_extensions==4.8.0
Werkzeug==2.3.0
WTForms==3.0.1

@ -0,0 +1,7 @@
from minibase import db, create_minibase
import minibase.database.utils as dbUtils
import minibase.database.models as model
app = create_minibase()
app.app_context().push()
Loading…
Cancel
Save