Skip to content

Commit

Permalink
Define database schema for organization
Browse files Browse the repository at this point in the history
Signed-off-by: ZhuoweiWen <[email protected]>
  • Loading branch information
ZhuoweiWen committed Jul 16, 2024
1 parent 911e3de commit e968124
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
16 changes: 12 additions & 4 deletions back-end/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@
from sqlalchemy.orm import relationship
from datetime import datetime

class organization(Base):
id = Column(Integer, primary_key=True)
name = Column(String(100), unique=True, nullable=False)
provider_id = Column(Integer)
brand_name = Column(String(50))
users = relationship('User', back_populates='organization')
folders = relationship('folder', back_populates='user', cascade='all, delete')
towers = relationship('tower', back_populates='user', cascade='all, delete')

class user(Base):
__tablename__ = 'user'

id = Column(Integer, primary_key=True)
username = Column(String(50), unique=True)
password = Column(String(256))
provider_id = Column(Integer)
brand_name = Column(String(50))
folders = relationship('folder', back_populates='user', cascade='all, delete')
towers = relationship('tower', back_populates='user', cascade='all, delete')
organization_id = Column(Integer, ForeignKey('organization.id'))
organization = relationship('Organization', back_populates='users')


class tower(Base):
__tablename__ = 'tower'
Expand Down
16 changes: 14 additions & 2 deletions front-end/components/Upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default function Upload() {
const currentYear = new Date().getFullYear();
const years = Array.from({ length: 10 }, (_, i) => currentYear - 5 + i);

const allowedExtensions = ["kml", "geojson", "csv"];


const fetchFolders = async () => {
Expand Down Expand Up @@ -159,11 +160,22 @@ export default function Upload() {
const handleFilingClick = (event) => {
event.preventDefault();

if (folderID === -1 && !files.some(file => file.file.name.endsWith('.csv'))) {
toast.error(
"Please upload your fabric",
{
position: toast.POSITION.TOP_RIGHT,
autoClose: 5000,
}
);
return; // Stop the function if the condition is met
}


const formData = new FormData();
formData.append("deadline", `${newDeadline.year}-${newDeadline.month}-03`);
formData.append("importFolder", importFolderID);
files.forEach((fileDetails) => {
const allowedExtensions = ["kml", "geojson", "csv"];
const fileExtension = fileDetails.file.name
.split(".")
.pop()
Expand Down Expand Up @@ -208,7 +220,7 @@ export default function Upload() {
} else if (response.status === 500 || response.status === 400) {
setIsLoading(false);
toast.error(
"Invalid File Format, please upload file with supported format",
"Error from our end, if issues persist, please contact support",
{
position: toast.POSITION.TOP_RIGHT,
autoClose: 10000,
Expand Down

0 comments on commit e968124

Please sign in to comment.