From 42d6f418f8f1d3edaaf498bb2ab62a665dbfd717 Mon Sep 17 00:00:00 2001 From: ncclarke Date: Sun, 20 Oct 2024 12:33:35 -0500 Subject: [PATCH 01/29] Updated to include quick note for running locally on windows machines --- docs/installation/basic.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/installation/basic.md b/docs/installation/basic.md index eb6137115b..fe9718e3f6 100644 --- a/docs/installation/basic.md +++ b/docs/installation/basic.md @@ -7,6 +7,9 @@ * Postgres * OpenSSL +### A quick note for Windows users +You may notice that you are unable to clone the project without a warning. Some files within the migrations/versions directory contain illegal file names for a windows system. The Open Event Server is not optimized for running localy on a Windows machine.Therefore it is suggested that you use Windows Subsystem for Linux(WSL), or a virtual machine to run the project locally. The setup steps for WSL can be found here: https://learn.microsoft.com/en-us/windows/wsl/install. Once using oen of these options you should be able to complete the following steps as usual. + ### For mac users ```sh brew install postgresql From 7d28938c7136427d2bd1daf6d2dbcaa40ad14ad2 Mon Sep 17 00:00:00 2001 From: ncclarke Date: Sun, 20 Oct 2024 12:44:16 -0500 Subject: [PATCH 02/29] fixed spelling mistakes --- docs/installation/basic.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/installation/basic.md b/docs/installation/basic.md index fe9718e3f6..51f755d02f 100644 --- a/docs/installation/basic.md +++ b/docs/installation/basic.md @@ -8,8 +8,7 @@ * OpenSSL ### A quick note for Windows users -You may notice that you are unable to clone the project without a warning. Some files within the migrations/versions directory contain illegal file names for a windows system. The Open Event Server is not optimized for running localy on a Windows machine.Therefore it is suggested that you use Windows Subsystem for Linux(WSL), or a virtual machine to run the project locally. The setup steps for WSL can be found here: https://learn.microsoft.com/en-us/windows/wsl/install. Once using oen of these options you should be able to complete the following steps as usual. - +You may notice that you are unable to clone the project without a warning. Some files within the migrations/versions directory contain illegal file names for a Windows system. The Open Event Server is not optimized for running locally on a Windows machine. Therefore, it is suggested that you use Windows Subsystem for Linux (WSL) or a virtual machine to run the project locally. The setup steps for WSL can be found here: https://learn.microsoft.com/en-us/windows/wsl/install. Once using one of these options, you should be able to complete the following steps as usual. ### For mac users ```sh brew install postgresql From 1e85664b716bbf37de3a06aa4f83b347f6fbe661 Mon Sep 17 00:00:00 2001 From: Tristan Nono <113402224+T2703@users.noreply.github.com> Date: Sun, 20 Oct 2024 19:04:27 -0500 Subject: [PATCH 03/29] Chore: Added documentation to sqlite_datetime_fix and its methods. --- app/models/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/utils.py b/app/models/utils.py index 5123ec69ee..f220877429 100644 --- a/app/models/utils.py +++ b/app/models/utils.py @@ -37,24 +37,31 @@ def checkout(dbapi_connection, connection_record, connection_proxy): "attempting to check out in pid %s" % (connection_record.info['pid'], pid) ) - +# Adjusts the DateTime handling for SQLite databases in SQLAlchemy by converting DateTime fields into an integer format that stores timestamps as seconds. def sqlite_datetime_fix(): + + # Converts DateTime objects to Unix timestamps before storage and converts them back to DateTime when retrieved. class SQLiteDateTimeType(types.TypeDecorator): impl = types.Integer epoch = datetime(1970, 1, 1, 0, 0, 0) + # Converts a DateTime object to Unix timestamp when storing the value in the SQLite database. def process_bind_param(self, value, dialect): return (value / 1000 - self.epoch).total_seconds() + # Converts a Unix timestamp back to a DateTime object when retrieving the value from the SQLite database. def process_result_value(self, value, dialect): return self.epoch + timedelta(seconds=value / 1000) + # Checks if the current database engine is SQLite. def is_sqlite(inspector): return inspector.engine.dialect.name == "sqlite" + # Checks if a given column is a DateTime. def is_datetime(column_info): return isinstance(column_info['type'], types.DateTime) + # Adjusts DateTime columns when reflecting tables in SQLite. @event.listens_for(Table, "column_reflect") def setup_epoch(inspector, table, column_info): if is_sqlite(inspector) and is_datetime(column_info): From 4005d1d751f2bb37b8ee5aac32cbcf3cf17900f7 Mon Sep 17 00:00:00 2001 From: Adam Jennissen Date: Sun, 20 Oct 2024 19:08:05 -0500 Subject: [PATCH 04/29] Small changes to the added note --- docs/installation/basic.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/installation/basic.md b/docs/installation/basic.md index 51f755d02f..04aa26dd2f 100644 --- a/docs/installation/basic.md +++ b/docs/installation/basic.md @@ -8,7 +8,8 @@ * OpenSSL ### A quick note for Windows users -You may notice that you are unable to clone the project without a warning. Some files within the migrations/versions directory contain illegal file names for a Windows system. The Open Event Server is not optimized for running locally on a Windows machine. Therefore, it is suggested that you use Windows Subsystem for Linux (WSL) or a virtual machine to run the project locally. The setup steps for WSL can be found here: https://learn.microsoft.com/en-us/windows/wsl/install. Once using one of these options, you should be able to complete the following steps as usual. +Some files within the migrations/versions directory contain illegal file names for a Windows system. The Open Event Server is not optimized for running locally on a Windows machine. Therefore, it is suggested that you use Windows Subsystem for Linux (WSL) or a virtual machine to run the project locally. The setup steps for WSL can be found here: https://learn.microsoft.com/en-us/windows/wsl/install. Once using one of these options, you should be able to complete the following linux setup steps within WSL. + ### For mac users ```sh brew install postgresql From 0492dc03cc384722e9cd642533783fbfdc4fa870 Mon Sep 17 00:00:00 2001 From: Cbolt17 <108592654+Cbolt17@users.noreply.github.com> Date: Sun, 20 Oct 2024 19:22:51 -0500 Subject: [PATCH 05/29] Update versioning.py with comments --- app/models/helpers/versioning.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/helpers/versioning.py b/app/models/helpers/versioning.py index f1cf920f97..8c57b00594 100644 --- a/app/models/helpers/versioning.py +++ b/app/models/helpers/versioning.py @@ -3,15 +3,21 @@ import bleach from bleach.callbacks import nofollow, target_blank +""" +Class to modify strings +""" +# Removes \r def remove_line_breaks(target_string: str) -> str: return target_string.replace('\r', '') +# Removes \n def strip_line_breaks(target_string: str) -> str: return target_string.replace('\n', '').replace('\r', '') +# Removes whitespace and \r, then removes \n if it contains a-z or A-Z def clean_up_string(target_string): if target_string: if not re.search('[a-zA-Z]', target_string): @@ -20,6 +26,7 @@ def clean_up_string(target_string): return target_string +# Makes html safe def clean_html(html, allow_link=False): if html is None: return None @@ -53,6 +60,7 @@ def clean_html(html, allow_link=False): ) +# Removes html from text def strip_tags(html): if html is None: return None From 865a29b44a23c70736a582825831db11ac5101eb Mon Sep 17 00:00:00 2001 From: LincolnOlsen Date: Sun, 20 Oct 2024 19:34:54 -0500 Subject: [PATCH 06/29] Lincoln's documentation edit on the app/api/admin_sales/events.py file --- app/api/admin_sales/events.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/api/admin_sales/events.py b/app/api/admin_sales/events.py index 23bb34d819..cd14b64fba 100644 --- a/app/api/admin_sales/events.py +++ b/app/api/admin_sales/events.py @@ -12,7 +12,8 @@ class AdminSalesByEventsSchema(Schema): """ - Sales summarized by event + Sales summarized by event. Mainly includes information on the event + itself, but also includes some info on the sales and tickets of the event. Provides event(name), From 3a5f2b3d9d47c98af76351728649035bbc03c7e6 Mon Sep 17 00:00:00 2001 From: Cbolt17 <108592654+Cbolt17@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:55:00 -0600 Subject: [PATCH 07/29] Add files via upload --- .github/workflows/pr-tests-and-build.yml | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/pr-tests-and-build.yml diff --git a/.github/workflows/pr-tests-and-build.yml b/.github/workflows/pr-tests-and-build.yml new file mode 100644 index 0000000000..cf6e3e3d52 --- /dev/null +++ b/.github/workflows/pr-tests-and-build.yml @@ -0,0 +1,39 @@ +name: PR Tests and Build + +on: + pull_request: + branches: + - development # Uses development branch + +jobs: + test-and-build: + name: Run Tests and Build + runs-on: ubuntu-latest + + steps: + # Checkout the code + - name: Checkout Code + uses: actions/checkout@v4 + + # Set up Python + - name: Set up Python 3.8 + uses: actions/setup-python@v5 + with: + python-version: 3.8 # Use version 3.8 + + # Install dependencies + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install poetry + poetry install + + # Run tests + - name: Run Tests + run: | + poetry run pytest tests + + # Build the project + - name: Build Project + run: | + poetry build From 1b9ed256a31e0b618ccb7707c3c71f414644105a Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:59:27 -0600 Subject: [PATCH 08/29] Readme for workflow --- Work_Flow_README.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Work_Flow_README.txt diff --git a/Work_Flow_README.txt b/Work_Flow_README.txt new file mode 100644 index 0000000000..bd3942bfe1 --- /dev/null +++ b/Work_Flow_README.txt @@ -0,0 +1,9 @@ +Workflow: +1.Wait for PR request +2.Pull the development branch +3.Run tests and Build + a.Checkout code + b.Setup Python + c.Install dependencies + d.Run tests + e.Build project \ No newline at end of file From 64e4c4b5513404606340381d1141b4bd0a943c1d Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:46:12 -0600 Subject: [PATCH 09/29] Add or update the Azure App Service build and deployment workflow config --- .../development_open-event-server.yml | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/development_open-event-server.yml diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml new file mode 100644 index 0000000000..7186a81c77 --- /dev/null +++ b/.github/workflows/development_open-event-server.yml @@ -0,0 +1,78 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions +# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions + +name: Build and deploy Python app to Azure Web App - open-event-server + +on: + push: + branches: + - development + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python version + uses: actions/setup-python@v5 + with: + python-version: '3.8' + + - name: Create and start virtual environment + run: | + python -m venv venv + source venv/bin/activate + + - name: Install dependencies + run: pip install -r requirements.txt + + # Optional: Add step to run tests here (PyTest, Django test suites, etc.) + + - name: Zip artifact for deployment + run: zip release.zip ./* -r + + - name: Upload artifact for deployment jobs + uses: actions/upload-artifact@v4 + with: + name: python-app + path: | + release.zip + !venv/ + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + permissions: + id-token: write #This is required for requesting the JWT + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: python-app + + - name: Unzip artifact for deployment + run: unzip release.zip + + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_25459C518E94458E9FFFC1EEB51BE4C9 }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_30C288E7351C44ADADF49E2BF7F2C108 }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_482C86EA4AE84C4B93BBCEAE71C65AB0 }} + + - name: 'Deploy to Azure Web App' + uses: azure/webapps-deploy@v3 + id: deploy-to-webapp + with: + app-name: 'open-event-server' + slot-name: 'Production' + \ No newline at end of file From 0d266978906642016323b8101bfc39af88be0c4e Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:58:36 -0600 Subject: [PATCH 10/29] Update development_open-event-server.yml --- .../development_open-event-server.yml | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index 7186a81c77..a4a6391135 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -27,8 +27,11 @@ jobs: python -m venv venv source venv/bin/activate - - name: Install dependencies - run: pip install -r requirements.txt + - name: Install dependencies using Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + poetry install + # Optional: Add step to run tests here (PyTest, Django test suites, etc.) @@ -49,8 +52,8 @@ jobs: environment: name: 'Production' url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - permissions: - id-token: write #This is required for requesting the JWT + permissions: + id-token: write #This is required for requesting the JWT steps: - name: Download artifact from build job @@ -61,13 +64,13 @@ jobs: - name: Unzip artifact for deployment run: unzip release.zip - - - name: Login to Azure - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_25459C518E94458E9FFFC1EEB51BE4C9 }} - tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_30C288E7351C44ADADF49E2BF7F2C108 }} - subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_482C86EA4AE84C4B93BBCEAE71C65AB0 }} + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_25459C518E94458E9FFFC1EEB51BE4C9 }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_30C288E7351C44ADADF49E2BF7F2C108 }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_482C86EA4AE84C4B93BBCEAE71C65AB0 }} - name: 'Deploy to Azure Web App' uses: azure/webapps-deploy@v3 @@ -75,4 +78,4 @@ jobs: with: app-name: 'open-event-server' slot-name: 'Production' - \ No newline at end of file + From 2fd323eb066170a316c54267c7d855731b3afeab Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:05:24 -0600 Subject: [PATCH 11/29] Update development_open-event-server.yml --- .github/workflows/development_open-event-server.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index a4a6391135..4d5be7cd1a 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -30,9 +30,9 @@ jobs: - name: Install dependencies using Poetry run: | curl -sSL https://install.python-poetry.org | python3 - + cd $GITHUB_WORKSPACE # Ensures we are in the repository root poetry install - # Optional: Add step to run tests here (PyTest, Django test suites, etc.) - name: Zip artifact for deployment From d4e0e87e880636f6f42e033a152b953a1d92749b Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:12:09 -0600 Subject: [PATCH 12/29] Update development_open-event-server.yml --- .github/workflows/development_open-event-server.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index 4d5be7cd1a..2d67cdfa85 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -16,6 +16,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: development - name: Set up Python version uses: actions/setup-python@v5 @@ -30,7 +32,7 @@ jobs: - name: Install dependencies using Poetry run: | curl -sSL https://install.python-poetry.org | python3 - - cd $GITHUB_WORKSPACE # Ensures we are in the repository root + source ~/.profile # Ensure Poetry is in PATH poetry install # Optional: Add step to run tests here (PyTest, Django test suites, etc.) From 452a3f2e51de920c0b71ce6b4bdabd6ae965b515 Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:21:27 -0600 Subject: [PATCH 13/29] Update development_open-event-server.yml --- .../development_open-event-server.yml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index 2d67cdfa85..1a2ea3ce8e 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -24,6 +24,27 @@ jobs: with: python-version: '3.8' + - name: Checkout master branch for pyproject.toml + uses: actions/checkout@v4 + with: + ref: master # Checkout the 'master' branch to get the pyproject.toml + path: master-branch + + - name: Copy pyproject.toml from master branch to development branch + run: | + cp master-branch/pyproject.toml . # Copy the pyproject.toml file + + - name: Set up Python version + uses: actions/setup-python@v5 + with: + python-version: '3.8' + + - name: Install dependencies using Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + source ~/.profile # Ensure Poetry is in PATH + poetry install # Install dependencies based on pyproject.toml + - name: Create and start virtual environment run: | python -m venv venv From 62ce0ce5a02811839f788fc16a7700d9b8b261cf Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:26:12 -0600 Subject: [PATCH 14/29] Update development_open-event-server.yml --- .../workflows/development_open-event-server.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index 1a2ea3ce8e..a37f1bd304 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -34,27 +34,16 @@ jobs: run: | cp master-branch/pyproject.toml . # Copy the pyproject.toml file - - name: Set up Python version - uses: actions/setup-python@v5 - with: - python-version: '3.8' - - - name: Install dependencies using Poetry - run: | - curl -sSL https://install.python-poetry.org | python3 - - source ~/.profile # Ensure Poetry is in PATH - poetry install # Install dependencies based on pyproject.toml - - name: Create and start virtual environment run: | python -m venv venv source venv/bin/activate - + - name: Install dependencies using Poetry run: | curl -sSL https://install.python-poetry.org | python3 - source ~/.profile # Ensure Poetry is in PATH - poetry install + poetry install # Install dependencies based on pyproject.toml # Optional: Add step to run tests here (PyTest, Django test suites, etc.) From 8beb415ed62958a304d2c4fdb95381b5a7ca1ebf Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Fri, 29 Nov 2024 18:06:01 -0600 Subject: [PATCH 15/29] Create .env --- .env | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000000..ff485c9b01 --- /dev/null +++ b/.env @@ -0,0 +1,14 @@ +# Azure PostgreSQL connection string +AZURE_POSTGRESQL_CONNECTIONSTRING="dbname=open-event-server-database host=open-event-server-server.postgres.database.azure.com port=5432 sslmode=require user=username password=password" + +# Test database URL +TEST_DATABASE_URL=postgresql:///opev_test + +# Integrate socket.io +INTEGRATE_SOCKETIO=false + +# App configuration +APP_CONFIG=config.DevelopmentConfig + +# Flask app instance +FLASK_APP=app.instance From 774946249401add35885de767b3c5ee22c279e71 Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Fri, 29 Nov 2024 18:11:27 -0600 Subject: [PATCH 16/29] Update config.py For Azure --- config.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 0fb0e0d91d..677dfa61e5 100644 --- a/config.py +++ b/config.py @@ -71,7 +71,21 @@ class Config: CSRF_ENABLED = True SERVER_NAME = env('SERVER_NAME', default=None) CORS_HEADERS = 'Content-Type' - SQLALCHEMY_DATABASE_URI = env('DATABASE_URL', default=None) + + # Fetch the Azure PostgreSQL connection string from the environment + conn_str = os.getenv('AZURE_POSTGRESQL_CONNECTIONSTRING') + if conn_str: + conn_str_params = {pair.split('=')[0]: pair.split('=')[1] for pair in conn_str.split(' ')} + + SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://{dbuser}:{dbpass}@{dbhost}/{dbname}?sslmode=require'.format( + dbuser=conn_str_params['user'], + dbpass=conn_str_params['password'], + dbhost=conn_str_params['host'], + dbname=conn_str_params['dbname'] + ) + else: + SQLALCHEMY_DATABASE_URI = env('DATABASE_URL', default=None) + SQLALCHEMY_ENGINE_OPTIONS = {'pool_pre_ping': True} SERVE_STATIC = env.bool('SERVE_STATIC', default=False) DATABASE_QUERY_TIMEOUT = 0.1 From 1806387dac008a8b1f779831131cf7454d1462c8 Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Fri, 29 Nov 2024 18:34:27 -0600 Subject: [PATCH 17/29] Update .env Added secret key --- .env | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.env b/.env index ff485c9b01..8d15df7a6b 100644 --- a/.env +++ b/.env @@ -12,3 +12,5 @@ APP_CONFIG=config.DevelopmentConfig # Flask app instance FLASK_APP=app.instance + +SECRET_KEY=c0d1ed3e21627542e448dc11657f9118466532a381cb63daacb2046bc301c199 From defa51a462c7cf8951add6798957877405fa553f Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Fri, 29 Nov 2024 19:19:29 -0600 Subject: [PATCH 18/29] Create common --- utils/common | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 utils/common diff --git a/utils/common b/utils/common new file mode 100644 index 0000000000..00d04adc8b --- /dev/null +++ b/utils/common @@ -0,0 +1,43 @@ +from marshmallow import pre_load + +from app.api.helpers.utilities import dasherize + + +def patch_defaults(schema, in_data): + """ + Add default values to None fields + :param schema: Schema + :param in_data: the json data comprising of the fields + :return: json data with default values + """ + for name, field in schema.fields.items(): + dasherized_name = dasherize(name) + attribute = in_data.get(dasherized_name) + if attribute is None: + in_data[dasherized_name] = field.default + return in_data + + +@pre_load +def make_object(schema, in_data): + """ + Returns the json data after adding defaults + :param schema: Schema + :param in_data: the json data comprising of the fields + :return: json data returned by the patch_default function + """ + return patch_defaults(schema, in_data) + + +def use_defaults(): + """ + Decorator added to model classes which have default values specified for one of it's fields + Adds the make_object method defined above to the class. + :return: wrapper + """ + + def wrapper(k, *args, **kwargs): + setattr(k, "make_object", eval("make_object", *args, **kwargs)) + return k + + return wrapper From c68da2670cc3b1b0d068e1e456de414fd03c4780 Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Fri, 29 Nov 2024 19:19:53 -0600 Subject: [PATCH 19/29] Add files via upload --- utils/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 utils/__init__.py diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000000..e69de29bb2 From 77a4ed43c4b95dbfcd8c16f4e610cce532f9af17 Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Sat, 30 Nov 2024 11:56:42 -0600 Subject: [PATCH 20/29] Update development_open-event-server.yml --- .github/workflows/development_open-event-server.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index a37f1bd304..913e561e2a 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -33,6 +33,7 @@ jobs: - name: Copy pyproject.toml from master branch to development branch run: | cp master-branch/pyproject.toml . # Copy the pyproject.toml file + cp -r master-branch/scripts . - name: Create and start virtual environment run: | From c68eed790cc02a2f0e283da4c4dcd6082a794ecb Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Sat, 30 Nov 2024 12:22:22 -0600 Subject: [PATCH 21/29] Delete utils directory --- utils/__init__.py | 0 utils/common | 43 ------------------------------------------- 2 files changed, 43 deletions(-) delete mode 100644 utils/__init__.py delete mode 100644 utils/common diff --git a/utils/__init__.py b/utils/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/utils/common b/utils/common deleted file mode 100644 index 00d04adc8b..0000000000 --- a/utils/common +++ /dev/null @@ -1,43 +0,0 @@ -from marshmallow import pre_load - -from app.api.helpers.utilities import dasherize - - -def patch_defaults(schema, in_data): - """ - Add default values to None fields - :param schema: Schema - :param in_data: the json data comprising of the fields - :return: json data with default values - """ - for name, field in schema.fields.items(): - dasherized_name = dasherize(name) - attribute = in_data.get(dasherized_name) - if attribute is None: - in_data[dasherized_name] = field.default - return in_data - - -@pre_load -def make_object(schema, in_data): - """ - Returns the json data after adding defaults - :param schema: Schema - :param in_data: the json data comprising of the fields - :return: json data returned by the patch_default function - """ - return patch_defaults(schema, in_data) - - -def use_defaults(): - """ - Decorator added to model classes which have default values specified for one of it's fields - Adds the make_object method defined above to the class. - :return: wrapper - """ - - def wrapper(k, *args, **kwargs): - setattr(k, "make_object", eval("make_object", *args, **kwargs)) - return k - - return wrapper From 4f38b4ad77c5d2001ad410d0febbef2c57c16ad3 Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Sat, 30 Nov 2024 12:33:42 -0600 Subject: [PATCH 22/29] Update development_open-event-server.yml --- .github/workflows/development_open-event-server.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index 913e561e2a..58f7a541e0 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -34,6 +34,14 @@ jobs: run: | cp master-branch/pyproject.toml . # Copy the pyproject.toml file cp -r master-branch/scripts . + cp -r master-branch/utils . + cp -r master-branch/static . + cp master-branch/package.json + cp master-branch/poetry.lock + cp master-branch/populate_db.py + cp master-branch/session_slides_type_to_json.py + cp master-branch/setup.cfg + cp master-branch/yarn.lock - name: Create and start virtual environment run: | From 3060823cfd673b89ea081b4efe2b0b756e8e906f Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Sat, 30 Nov 2024 12:38:17 -0600 Subject: [PATCH 23/29] Update development_open-event-server.yml --- .github/workflows/development_open-event-server.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index 58f7a541e0..05901d5a99 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -36,12 +36,12 @@ jobs: cp -r master-branch/scripts . cp -r master-branch/utils . cp -r master-branch/static . - cp master-branch/package.json - cp master-branch/poetry.lock - cp master-branch/populate_db.py - cp master-branch/session_slides_type_to_json.py - cp master-branch/setup.cfg - cp master-branch/yarn.lock + cp master-branch/package.json . + cp master-branch/poetry.lock . + cp master-branch/populate_db.py . + cp master-branch/session_slides_type_to_json.py . + cp master-branch/setup.cfg . + cp master-branch/yarn.lock . - name: Create and start virtual environment run: | From 17c7f0e6f245b74d69c05fe4cadde28302c8382a Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:15:00 -0600 Subject: [PATCH 24/29] Update development_open-event-server.yml --- .github/workflows/development_open-event-server.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index 05901d5a99..5b003817c1 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -53,6 +53,16 @@ jobs: curl -sSL https://install.python-poetry.org | python3 - source ~/.profile # Ensure Poetry is in PATH poetry install # Install dependencies based on pyproject.toml + sudo apt-get update + sudo apt-get install libmagic1 libmagic-dev + sudo apt-get install libpq-dev + sudo apt-get install libffi6 libffi-dev + sudo apt-get update + sudo apt-get install libcairo2 libcairo2-dev + sudo apt-get update + sudo apt-get install libpango-1.0-0 libpango1.0-dev + + # Optional: Add step to run tests here (PyTest, Django test suites, etc.) From ff694d3b2c34373bdee73e7ccf194fbd588a1d49 Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:19:38 -0600 Subject: [PATCH 25/29] Update development_open-event-server.yml --- .github/workflows/development_open-event-server.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index 5b003817c1..a7ba1c4926 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -56,8 +56,6 @@ jobs: sudo apt-get update sudo apt-get install libmagic1 libmagic-dev sudo apt-get install libpq-dev - sudo apt-get install libffi6 libffi-dev - sudo apt-get update sudo apt-get install libcairo2 libcairo2-dev sudo apt-get update sudo apt-get install libpango-1.0-0 libpango1.0-dev From 54531e356391012b544ca63855262e337d08ff56 Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:57:44 -0600 Subject: [PATCH 26/29] Update development_open-event-server.yml --- .github/workflows/development_open-event-server.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index a7ba1c4926..6f3a64f0fc 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -59,6 +59,7 @@ jobs: sudo apt-get install libcairo2 libcairo2-dev sudo apt-get update sudo apt-get install libpango-1.0-0 libpango1.0-dev + pip install python-magic From a930a7815efbc37b67222aecdb18282897bd80d4 Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Tue, 3 Dec 2024 18:15:42 -0600 Subject: [PATCH 27/29] Update development_open-event-server.yml --- .github/workflows/development_open-event-server.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index 6f3a64f0fc..38b263af20 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -55,10 +55,12 @@ jobs: poetry install # Install dependencies based on pyproject.toml sudo apt-get update sudo apt-get install libmagic1 libmagic-dev + sudo apt-get update sudo apt-get install libpq-dev sudo apt-get install libcairo2 libcairo2-dev sudo apt-get update sudo apt-get install libpango-1.0-0 libpango1.0-dev + sudo apt-get update pip install python-magic From 645358c4bfc3d88e121974eb1466155b8fcf8c6b Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Tue, 3 Dec 2024 18:31:35 -0600 Subject: [PATCH 28/29] Update development_open-event-server.yml --- .github/workflows/development_open-event-server.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index 38b263af20..f4fc01f0fd 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -54,7 +54,7 @@ jobs: source ~/.profile # Ensure Poetry is in PATH poetry install # Install dependencies based on pyproject.toml sudo apt-get update - sudo apt-get install libmagic1 libmagic-dev + sudo apt-get install libmagic-dev sudo apt-get update sudo apt-get install libpq-dev sudo apt-get install libcairo2 libcairo2-dev From fd9e0218418303833a46b4bf7225bdb245f1061c Mon Sep 17 00:00:00 2001 From: Nathaniel Clarke <144461144+ncclarke@users.noreply.github.com> Date: Tue, 3 Dec 2024 18:51:59 -0600 Subject: [PATCH 29/29] Update development_open-event-server.yml --- .github/workflows/development_open-event-server.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/development_open-event-server.yml b/.github/workflows/development_open-event-server.yml index f4fc01f0fd..45d379ff94 100644 --- a/.github/workflows/development_open-event-server.yml +++ b/.github/workflows/development_open-event-server.yml @@ -61,7 +61,7 @@ jobs: sudo apt-get update sudo apt-get install libpango-1.0-0 libpango1.0-dev sudo apt-get update - pip install python-magic +