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

Clarification Changes #9141

Open
wants to merge 31 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
42d6f41
Updated to include quick note for running locally on windows machines
ncclarke Oct 20, 2024
7d28938
fixed spelling mistakes
ncclarke Oct 20, 2024
1e85664
Chore: Added documentation to sqlite_datetime_fix and its methods.
T2703 Oct 21, 2024
4005d1d
Small changes to the added note
AdamMJennissen Oct 21, 2024
0492dc0
Update versioning.py with comments
Cbolt17 Oct 21, 2024
b3b913a
Merge branch 'development' of github.com:ncclarke/open-event-server i…
AdamMJennissen Oct 21, 2024
865a29b
Lincoln's documentation edit on the app/api/admin_sales/events.py file
LincolnOlsen Oct 21, 2024
de0e5b4
Merge branch 'development' of https://github.com/ncclarke/open-event-…
LincolnOlsen Oct 21, 2024
3a5f2b3
Add files via upload
Cbolt17 Nov 21, 2024
1b9ed25
Readme for workflow
ncclarke Nov 21, 2024
64e4c4b
Add or update the Azure App Service build and deployment workflow config
ncclarke Nov 23, 2024
0d26697
Update development_open-event-server.yml
ncclarke Nov 23, 2024
2fd323e
Update development_open-event-server.yml
ncclarke Nov 23, 2024
d4e0e87
Update development_open-event-server.yml
ncclarke Nov 23, 2024
452a3f2
Update development_open-event-server.yml
ncclarke Nov 23, 2024
62ce0ce
Update development_open-event-server.yml
ncclarke Nov 23, 2024
8beb415
Create .env
ncclarke Nov 30, 2024
7749462
Update config.py
ncclarke Nov 30, 2024
1806387
Update .env
ncclarke Nov 30, 2024
defa51a
Create common
ncclarke Nov 30, 2024
c68da26
Add files via upload
ncclarke Nov 30, 2024
77a4ed4
Update development_open-event-server.yml
ncclarke Nov 30, 2024
c68eed7
Delete utils directory
ncclarke Nov 30, 2024
4f38b4a
Update development_open-event-server.yml
ncclarke Nov 30, 2024
3060823
Update development_open-event-server.yml
ncclarke Nov 30, 2024
17c7f0e
Update development_open-event-server.yml
ncclarke Dec 3, 2024
ff694d3
Update development_open-event-server.yml
ncclarke Dec 3, 2024
54531e3
Update development_open-event-server.yml
ncclarke Dec 3, 2024
a930a78
Update development_open-event-server.yml
ncclarke Dec 4, 2024
645358c
Update development_open-event-server.yml
ncclarke Dec 4, 2024
fd9e021
Update development_open-event-server.yml
ncclarke Dec 4, 2024
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
16 changes: 16 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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

SECRET_KEY=c0d1ed3e21627542e448dc11657f9118466532a381cb63daacb2046bc301c199
113 changes: 113 additions & 0 deletions .github/workflows/development_open-event-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# 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
with:
ref: development

- name: Set up Python version
uses: actions/setup-python@v5
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
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: |
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 # Install dependencies based on pyproject.toml
sudo apt-get update
sudo apt-get install 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




# 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'

39 changes: 39 additions & 0 deletions .github/workflows/pr-tests-and-build.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions Work_Flow_README.txt
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion app/api/admin_sales/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 8 additions & 0 deletions app/models/helpers/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion app/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 15 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/installation/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* Postgres
* OpenSSL

### A quick note for Windows users
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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (documentation): Consider using markdown link format for the WSL setup instructions.

For consistency with markdown formatting, you might want to use the following format: WSL setup instructions

Suggested change
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.
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 [WSL setup instructions](https://learn.microsoft.com/en-us/windows/wsl/install) can be found here. 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
Expand Down
6 changes: 0 additions & 6 deletions package.json

This file was deleted.

Loading