-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadme.txt
138 lines (105 loc) · 5.37 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#################################################
# IMPORTANT: DO NOT PIP FREEZE REQUIREMENTS.TXT!!
"""""""""""""""""""""""""""""""""""""""""""""""""
# ***IMPT Deployment Notes:***
# AWS has specific packages that are different to windows, so DON'T freeze requirements!
# A backup copy as of 28Jun23 has been taken
# This version has been tested and deployed for Elastic Beanstalk/CodePipeline
# Python 3.7 running on 64bit Amazon Linux <-- This does NOT work on Amazon Linux 2023 due to pg_config incompatibility (amazon-linux-extras no longer exists on Amazon Linux 2023).
# Note: Successfully deployed on the staging env with all ports open - This needs to be closed for security purposes!
>> cd /boostly
>> venv\Scripts\activate
# Install the requirements
pip install -r requirements.txt
>> in TLD
# One time setup to allow for easy running of Flask app
>> set FLASK_APP=application.py
# Test to see if it works
>> flask run
# To run app, in (venv)
python boostly.py
flask shell
from boostly import app
# FOR EB DEPLOYMENTS
Make sure that the following are NOT in the requirements.txt file!!
pypiwin32==223
pywin32==305
Make sure that main application is renamed to application.py and the flask app is also application and not another name. Refactor using Pycharm!!
Make sure that .idea and __pycache__ files are deleted before upload
user_1 = User(userFirstName='Chris', userLastName='DaTester', userEmail='chris.chonghuihui@gmail.com', userPassword='superDev!')
####################################
# Tips & Tricks
#----------------------------------
# To get out of venv
>> venv\Scripts\deactivate
## Basic sqlite db connectivity
# In TLD:
> python
>> from boostly import db
>> db.create_all()
## To add a user, after <<flask shell>> and <<create_all()>>, create a user using e.g.
user_1 = User(userEmail='new@test.com', userPassword="password!")
db.session.add(user_1)
db.session.commit() ## commits it to the DB
## Query users using:
User.query.all()
user = User.query.filter_by(userEmail="new@test.com".first()
user.id
## Adding a task (tied to user defined above)
task_1 = Task(taskTitle="Connect to DB", taskDescription="help!!!", userID=user.id, taskDue="02/03/23")
db.session.add(task_1)
db.session.commit()
## To clear db of all entries, use
db.drop_all()
from boostly.models import AvailTimes, Client, ClientCompany, ClientPref, Company, Event, PrefTimes, TempWaitAlert, User
# Some adds
from boostly import db
db.create_all()
from boostly.models import AvailTimes, Client, ClientCompany, ClientPref, Company, Event, PrefTimes, TempWaitAlert, User
coy1 = Company(companyName="Lena Massage")
db.session.add(coy1)
db.session.commit()
user1 = User(userFirstName="Testy", userLastName="Tester", userEmail="test@test.com", userPassword="$2b$12$6Lxi6jt8RtxNlggq9ugHlusxuDmbydw084Gl5IfQfcSVjERO6vtLu", companyid=1)
db.session.add(user1)
db.session.commit()
staff1 = Staff(firstName="The", lastName="Therapist", prefName="Terry", email="terry@pist.com", service="", bookURL="", userid=1)
client1 = Client(firstName="Richie", lastName="Rich", email="richie@rich.com", staffid=2)
alert1 = TempWaitAlert(slotStartDateTime="2023-05-16 20:15:00", slotLength=45)
alert2 = TempWaitAlert(slotStartDateTime="2023-06-01 11:30:00", slotLength=120)
user1 = User(userFirstName="Testy", userLastName="Tester", userEmail="test@test.com", userPassword="$2b$12$6Lxi6jt8RtxNlggq9ugHlusxuDmbydw084Gl5IfQfcSVjERO6vtLu")
staff1 = Staff(firstName="Testy", lastName="Therapist", prefName="Terry", email="terry@pist.com", service="", bookURL="", userid=1)
client1 = Client(firstName="Baby", lastName="Yoda", email="yoda@client.com", mobile=220220222)
# Prepopulating the db with timeslots
# (Not sure if this is acceptable, but coded this way so that it's clear what availtime options there are)
av1=AvailTimes(timeUnit='Monday')
av2=AvailTimes(timeUnit='Tuesday')
av3=AvailTimes(timeUnit='Wednesday')
av4=AvailTimes(timeUnit='Thursday')
av5=AvailTimes(timeUnit='Friday')
av6=AvailTimes(timeUnit='Saturday')
av7=AvailTimes(timeUnit='Sunday')
db.session.add(av1)
db.session.add(av2)
db.session.add(av3)
db.session.add(av4)
db.session.add(av5)
db.session.add(av6)
db.session.add(av7)
db.session.commit()
cp1=ClientPref(minDuration=60)
availList = [ AvailTimes('Monday AM'), AvailTimes('Monday PM'),
AvailTimes('Tuesday AM'), AvailTimes('Tuesday PM'),
AvailTimes('Wednesday AM'), AvailTimes('Wednesday PM'),
AvailTimes('Thursday AM'), AvailTimes('Thursday PM'),
AvailTimes('Friday AM'), AvailTimes('Friday PM'),
AvailTimes('Saturday AM'), AvailTimes('Saturday PM'),
AvailTimes('Sunday AM'), AvailTimes('Sunday PM')]
for each in availList:
db.session.add(each)
db.session.commit()
<button class="btn btn-success btn-sm rounded-0" type="button" data-toggle="tooltip" data-placement="top" title="Edit"><i class="fa fa-edit"></i></button>
#### IMPORTANT!!! ####
MAKE SURE THAT AWS SECURITY CREDENTIALS ARE SET FOR ELASTIC BEANSTALK!
https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/deployment-beanstalk-specify-credentials.html
# Go to https://us-east-1.console.aws.amazon.com/iamv2/home#/users/details/ses-smtp-user.20230619-171053?section=permissions
# Under Security Credentials, select Create Access Key and make sure that you select the option for SES/AWS resources