Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Database #10

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SECRET_KEY='DEVElOPMENTONLY'
SQLALCHEMY_DATABASE_URI='postgresql://usr:pwd@postgres:5433/master'
SQLALCHEMY_DATABASE_URI='postgresql://usr:pwd@postgres:5432/master'

22 changes: 22 additions & 0 deletions api/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE "User" (
"id" SERIAL UNIQUE PRIMARY KEY,
"session_id" uuid UNIQUE,
"email" TEXT UNIQUE,
"password" uuid
);

CREATE TABLE "Files" (
"id" SERIAL UNIQUE PRIMARY KEY,
"user_id" INTEGER UNIQUE,
"location" TEXT,
"bug_name" TEXT,
"file_name" TEXT,
FOREIGN KEY ("user_id") REFERENCES "User"("id")a
);

CREATE TABLE "Species" (
"id" SERIAL UNIQUE PRIMARY KEY,
"name" TEXT,
"description" TEXT,
"remove" BOOLEAN
);
42 changes: 36 additions & 6 deletions api/pollination/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'''
Contains the table representations of the database
'''

import string
import random
from uuid import uuid4
Expand Down Expand Up @@ -29,12 +28,43 @@ class User(db.Model):
id = db.Column(db.String(32), primary_key=True,
unique=True, default=get_uuid)
alt_id = db.Column(db.String(6), unique=True, default=get_basic_id)
username = db.Column(db.Text, unique=True)

team_name = db.Column(db.String(20), unique=True)
track_value = db.relationship('Track_value', back_populates='team')

user = db.relationship('User', back_populates='team')
file = db.Relationship('File', back_populates='user',
cascade='all, delete', passive_deletes=True)
# Determine what access level the function is at

def __repr__(self):
return f"Team('{self.team_name}','{ self.alt_id }')"
return f"Team('{self.name}','{ self.alt_id }')"


class File(db.Model):
'''
Correlates the file location with the User
'''
__tablename__ = "File"
id = db.Column(db.Integer, primary_key=True, unique=True)
user_id = db.Column(db.String(32), db.ForeignKey('User.id',
ondelete="CASCADE"), nullable=False)
location = db.Column(db.Text)
bug_name = db.Column(db.Text)
file_name = db.Column(db.Text)
user = db.Relationship('User', back_populates='file')

def __repr__(self):
return f"File('{self.location}', '{self.bug_name}', \
'{self.file_name}')"


class Species(db.Model):
'''
Contains a database of species to search for
'''
__tablename__ = "Species"
id = db.Column(db.Integer, primary_key=True, unique=True)
plant = db.Column(db.Boolean)
name = db.Column(db.Text)
description = db.Column(db.Text)
native = db.Column(db.Boolean)
location = db.Column(db.Text)
image_location = db.Column(db.Text)
11 changes: 11 additions & 0 deletions api/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# pylint: skip-file
from pollination import db
from pollination.models import User

if __name__ == "__main__":
db.drop_all()
db.create_all()

user = User(name="moo", email="testing@gmail.com")
db.session.add(user)
db.session.commit()
Empty file added client/app/css/colors.css
Empty file.
Empty file added client/app/templates/base.jsx
Empty file.
Loading