-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsite_information.txt
243 lines (164 loc) · 7.97 KB
/
site_information.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
Logging into NAU CEFNS to update team website ( must be connected to nau wifi )
ssh cch264@linux.cefns.nau
Directory where our website folder is stored
/www/ceias.nau.edu/capstone/projects/CS/2022/RedAlert
PROGRAM VERSIONS:
Django==3.2.8
djongo==1.3.6
pymongo==3.12.2
mongoDB==4.4.4
Generate a new Django app:
python manage.py startapp your_app_name
Twilio and Email Information:
Email Info:
Email: redalerttester@gmail.com
Email Password: CS486RedAlert
________________________________________________________
Twilio Info:
Twilio Account Username: redalerttester@gmail.com
Twilio Account Password: CS486RedAlertSMS
Twilio Phone Number: +19087749012
Twilio Account SID: ACd232a36bec0e51f5a8d55b978f773c56
Twilio Account Auth: 678c512574c3642b3824a2a5ccce9c59
The folder mysite/ the name can be anything and is simply a container for the project.
The folder mysite/mysite/ is directory is the actual Python package for your project. Its name is the Python package name you’ll need to use to import anything inside it
This is the folder you will usually by inside of.
Django root directory is the directory that contains manage.py
What are apps in Django?
An app is a Web application that does something – e.g., a Weblog system,
a database of public records or a small poll app. An app can be in multiple projects.
What are projects in Django?
A project is a collection of configuration and apps for a particular website.
A project can contain multiple apps.
Create the db with this command: python manage.py migrate
Creates your database accoriding to settings in the mysite/settings.py file and existing
db migrations shipped with django.
'python manage.py makemigrations polls' Tells Django youve made some changes to your models.
and that you want your changes to be stored as a migration. This means you model infomation is
saved into migrations files which can then be run using python manage.py migrate. This command actually
makes changes to the database. This command only runs migrations that havent been run yet.
'python manage.py createsuperuser' Creates a new user that can access the Django admin console.
'python manage.py runserver' Start the DEV server. Uses a small lightweight server
built into Djanog, not for prod at all.
python manage.py shell
Allows you to open an interactive python shell that can make changes to your site and db.
'https://pymongo.readthedocs.io/en/stable/installation.html' Go here and install pymongo to use mongodb with Django.
Install Django:
pip3 install Django
Install DJONGO
'pip install djongo'
DOWNGRADE PYMONGO
'python -m pip install pymongo==3.12.2'
For some reason pymongo 4.0 doesnt work with djongo so downgrade it to this.
Not sure why or how I was supposed to know that but someone on stackoverflow recommended to downgrade pymongo.
https://stackoverflow.com/questions/70185942/why-i-am-getting-not-implemented-error-
database-objects-do-not-implement-truth
Djongo allows us to use Django as if we had a relational database, so refer to this as a reference
https://docs.djangoproject.com/en/3.2/intro/tutorial02/ when working with database data in django. The tutorial
is using an interactive shell but it works the same in the actual Djanog view code.
https://www.djongomapper.com/get-started/ -- shows you how to use Djangos built in relational object methods
to interact with the mongodb database.
Create new Django App
python manage.py startapp user_login_app
Install Jquery for your django app
cd into your root project templates file
ex: "/home/calvin/Documents/NAUClasses/CS476_486/red_alert_site/RedAlert/static"
run the command "wget https://code.jquery.com/jquery-3.6.0.min.js"
This downloads a compressed folder containing jquery source code.
Install apschedular
pip install apscheduler
pip freeze | grep pymongo - view what version of pymongo is running on your project
pip freeze | grep djongo
Setting up the Django Environment Variables file
Create .env file inside the same directory as settings.py
install this -> 'pip install django-environ'
Now inside your .env file define variables in the form TEST_VAR="VALUE"
The in settings.py, add these lines
import environ
env = environ.Env()
environ.Env.read_env()
Access vars from the .env file with this syntax: env("TEST_VAR")
Install Twilio With Pip
pip install "django-sms[twilio]"
Install Nginx
sudo apt install nginx
Remove enabled site that you dont need.
rm /etc/nginx/sites-enabled/default
Resetting database migrations in django
On linux run this command, (Delete all files in migrations folder except the __init__.py file)
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
Now run this cmd ( Delete cached migration files )
find . -path "*/migrations/*.pyc" -delete
Now run migrtations as normal
python manage.py makemigrations
python manage.py migrate
Allow NGINx through firewall by using UFW
sudo ufw allow 'Nginx Full'
Allow SSH to server DO THIS BEFORE STARTING UFW or else you cant connect back to the server
sudo ufw allow ssh
Server commands:
Restart Server After Making Changes
sudo systemctl restart gunicorn
The templatetags folder holds custom defined filter functions created by the user to be used in html templates.
MONGODB:
connect to mongodb shell 'mongo'
Show all databases 'show databases'
Collections are like tables, collections hold documents, and each document has an id or object id which is
like a primary key.
'use dbname' to use or create a db
'db.dropDatabase()' to delete a db
'db.createCollection('collectionName')' create a collection, which is like a table with the given name
'db.collectionName.insert({key: 'value', date: Date(), likes: 4, tags: ['news', 'events'], user: {name: 'Johny', status: 'author', age: 99} })'
insert a value into the collection, like inserting a row in sql.
'show collections' shows all the collections in the db
'db.collectionName.find().pretty()' - shows all documents in the collection. pretty is optional but makes it the output look nice.
'db.posts.find({ category: 'News'}).pretty()' Finds the document in posts that has category equal to 'News'.
Delete all docs in a collection
db.userLoginApp_userinfo.deleteMany({})
Delete one doc from collection
db.collectionname.deleteOne( { field_name: value_either_string_or_int } )
List information about running db server
db.serverCmdLineOpts()
127.0.0.1:60924
db name: red_alert_db_development
Show ipaddress and port number for running db server
db.runCommand({whatsmyuri : 1})
Start Stop or Restart mongodb local server
sudo systemctl status mongodb
sudo systemctl stop mongodb
sudo systemctl start mongodb
sudo systemctl restart mongodb
UNMASK MONGODB service. If your system says mongodb service not found do this.
sudo service mongod start
Using the database on the server with username and pass ( type these commands )
use admin
db.auth("redalertadmin", passwordPrompt())
Kill mongo service:
ps -edaf | grep mongo | grep -v grep
kill pid_of_process
Change phone number of all clients in mongoDB database
db.redAlertSite_client.updateMany({},{$set:{phone:Long("12252542523")}})
Start mongodb with user account requirement. If you start the service with this command then you will
need a username and password to login.
You must start the mongodb server with this command or else the site will not work.
mongod --auth
Edit conf file for service.
sudo vim systemctl edit --full mongodb.service
db.createUser(
{
user: "redalertadmin",
pwd: passwordPrompt(), // or cleartext password
roles: [
{ role: "userAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" }
]
}
)
Port: 27017
HOST: hwsrv-937117.hostwindsdns.com
Meeting Notes:
Dont need agent birthday or address. Change agent address to Agency Address. Just remove it from the sign up page.
Move filters to the left side of search bar.
Combine filters into a single drop down.
Add dynamic city filter based on client city.
Client ID: 1000-1022