Skip to content
This repository was archived by the owner on Feb 2, 2022. It is now read-only.

Feedback #1

Open
wants to merge 53 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
d41e6ea
Setting up GitHub Classroom Feedback
github-classroom[bot] Dec 1, 2021
a3c16ae
Installing django
Dec 1, 2021
8997ea3
Linking with MongoDB, preparing for GCloud upload
Dec 2, 2021
c570922
Deploying to GCloud
Dec 2, 2021
6da31db
Adjusting to Python3.9
Dec 2, 2021
33a7102
Adding requirements
Dec 2, 2021
26c6d5e
main.py to fix 502 error on gcloud
Dec 2, 2021
8db5b26
adding main.py to fix gcloud 502 error
Dec 2, 2021
ee2f739
fix 502 error gcloud by importing wsgi
Dec 4, 2021
ba19e66
fix allowed host error gcloud
Dec 4, 2021
161700c
Remove MongoDB operations, set up for Firebase auth
Dec 5, 2021
1251a0d
Implement Firebase authentication (untested)
Dec 5, 2021
e866d35
Add secret ignore
Dec 5, 2021
2c19c59
Add secrets ignore
Dec 5, 2021
169437b
Add reference to source material
Dec 5, 2021
6ffabad
Add users app from other project
Dec 5, 2021
78b043a
Adding firebase registration
Dec 7, 2021
1a5d6f5
Merge pull request #3 from BUCOMPAdvancedDevelopment/firebaseAuth
nerdferby Dec 7, 2021
c226f2e
Merge branch 'main' of https://github.com/BUCOMPAdvancedDevelopment/a…
Dec 7, 2021
981e09d
Amend registration data, remove db setting
Dec 7, 2021
bc968a3
Parcel app
Dec 13, 2021
e73e030
Refactoring, begin db integration, product and orders
Dec 13, 2021
5d85bd3
Integrate MongoDB, test firebase auth and register
Dec 15, 2021
ea36e99
GCloud config
nerdferby Dec 16, 2021
984d462
Move firebase auth from form to view
Dec 16, 2021
1ee4986
Configure gunicorn and firebase_admin requirements
nerdferby Dec 16, 2021
9651932
Resolve merge conflict
Dec 16, 2021
9999e07
Reconfigure BASE_DIR
Dec 16, 2021
ed2de76
Working firebase intgeration
nerdferby Dec 19, 2021
57ad72a
User Interface and bootstrap
Dec 20, 2021
28be4e9
Add secret integration, refactoring, user interface design
Dec 21, 2021
9eaa049
Merge pull request #4 from BUCOMPAdvancedDevelopment/user_interface
nerdferby Dec 21, 2021
872fde6
Remove firebase integration
Jan 1, 2022
a92355f
Merge pull request #5 from BUCOMPAdvancedDevelopment/user_interface
nerdferby Jan 1, 2022
61575a1
Firebase firestore database initial integration
Jan 1, 2022
cfce26a
Login form and view
nerdferby Jan 2, 2022
2fe1fe0
Secrets fallback
Jan 2, 2022
a4a6be1
Basic login functionality and forms
Jan 2, 2022
86b2b2a
Create products, firestore integration
Jan 2, 2022
1694e65
Product view, firebase auth setup
Jan 3, 2022
deef6f6
Remove Firebase Auth. Login form
Jan 3, 2022
05a524a
Product and Order basic functionality
Jan 3, 2022
33650e7
Refactoring and optimisations
Jan 3, 2022
6ada1ec
Refactor and documentation
Jan 4, 2022
edfd2ca
Authentication refactoring
Jan 4, 2022
f2e228b
Fix attributeerror logged in
Jan 4, 2022
dc2c0b9
Fix reversed login authentication
Jan 4, 2022
605406e
Refactoring, optimisation, argon2 password hash
Jan 6, 2022
340edb7
Revert "Refactoring, optimisation, argon2 password hash"
Jan 6, 2022
6ccb14c
Cherry pick markup and view refactoring
Jan 6, 2022
c1d4203
Final commit
Jan 6, 2022
cdebecc
Jumbotron copy
Jan 6, 2022
550bd68
Last minute bug fixes
nerdferby Jan 6, 2022
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
19 changes: 19 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file specifies files that are *not* uploaded to Google Cloud
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

# Python pycache:
__pycache__/
# Ignored by the build system
/setup.cfg
143 changes: 143 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Django #
*.log
*.pot
*.pyc
__pycache__
db.sqlite3
media

# Backup files #
*.bak

# If you are using PyCharm #
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# File-based project format
*.iws

# IntelliJ
out/

# JIRA plugin
atlassian-ide-plugin.xml

# Python #
*.py[cod]
*$py.class

# Distribution / packaging
.Python build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
.pytest_cache/
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery
celerybeat-schedule.*

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# mkdocs documentation
/site

# mypy
.mypy_cache/

# Sublime Text #
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
*.sublime-workspace
*.sublime-project

# sftp configuration file
sftp-config.json

# Package control specific files Package
Control.last-run
Control.ca-list
Control.ca-bundle
Control.system-ca-bundle
GitHub.sublime-settings

# Visual Studio Code #
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history

# Python package installation files #
*.whl

firebase_admin_sdk.json
django_secret_key.txt
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions .idea/AdvancedDevelopment.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions AdvancedDevelopment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pymongo
from pymongo import MongoClient
from pymongo.errors import BulkWriteError

# cluster = MongoClient("mongodb+srv://s5124723:UJZ6xxtNrnYwSNWowyz8@advanceddevelopment.aiiro.mongodb.net/test")
# db = cluster["AdvancedDevelopment"]
# collection = db["test"]

# try:
# post1 = {"_id": 1, "name": "Lucas", "score": 5}
# post2 = {"_id": 2, "name": "Daniel", "score": 5}
# collection.insert_many([post1, post2])
# except BulkWriteError as bwe:
# print(bwe)
#
16 changes: 16 additions & 0 deletions AdvancedDevelopment/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for AdvancedDevelopment project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'AdvancedDevelopment.settings')

application = get_asgi_application()
55 changes: 55 additions & 0 deletions AdvancedDevelopment/firebase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
Firebase admin interface used for connecting to and amending
Firestore database
"""

import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore

# Use the application default credentials
cred = credentials.ApplicationDefault()
firebase_admin.initialize_app(cred, {
'projectId': 'idyllic-kit-328813',
})


class FirebaseClient:
"""Source: https://github.com/saadmk11/django-todo"""

def __init__(self, collection):
self._db = firestore.client()
self._collection = self._db.collection(str(collection))

def create(self, data, document: str = None):
"""Create item in firestore database"""
doc_ref = self._collection.document(document)
doc_ref.set(data)

def update(self, document, data):
"""Update item on firestore database using document id"""
doc_ref = self._collection.document(document)
doc_ref.update(data)

def delete_by_id(self, document):
"""Delete item on firestore database using document id"""
self._collection.document(document).delete()

def get_by_id(self, document):
"""Get item on firestore database using document id"""
doc_ref = self._collection.document(document)
doc = doc_ref.get()

if doc.exists:
return {**doc.to_dict(), "id": doc.id}
return False

def all(self):
"""Get all item from firestore database"""
docs = self._collection.stream()
return [{**doc.to_dict(), "id": doc.id} for doc in docs]

def filter(self, field, condition, value):
"""Filter item using conditions on firestore database"""
docs = self._collection.where(field, condition, value).stream()
return [{**doc.to_dict(), "id": doc.id} for doc in docs]
10 changes: 10 additions & 0 deletions AdvancedDevelopment/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from AdvancedDevelopment.wsgi import application as app

# App Engine by default looks for a main.py file at the root of the app
# directory with a WSGI-compatible object called app.
# This file imports the WSGI-compatible object of your Django app,
# application from mysite/wsgi.py and renames it app so it is discoverable by
# App Engine without additional configuration.
# Alternatively, you can add a custom entrypoint field in your app.yaml:
# entrypoint: gunicorn -b :$PORT mysite.wsgi
# https://stackoverflow.com/questions/52395695/modulenotfounderror-no-module-named-main-when-attempting-to-start-service
11 changes: 11 additions & 0 deletions AdvancedDevelopment/secrets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from google.api_core.exceptions import PermissionDenied
from google.cloud import secretmanager


def get_secret(name: str, fallback, client=None):
if not client:
client = secretmanager.SecretManagerServiceClient()
try:
return client.access_secret_version(name=name)
except PermissionDenied as error:
return fallback()
Loading