Skip to content

Commit

Permalink
Merge pull request #319 from djangonaut-space/develop
Browse files Browse the repository at this point in the history
Production Release - Surveys, supervisor, python 3.11, blog formatting
  • Loading branch information
tim-schilling authored Mar 22, 2024
2 parents a58094d + 4c02b49 commit 37df9b0
Show file tree
Hide file tree
Showing 70 changed files with 1,905 additions and 1,576 deletions.
6 changes: 2 additions & 4 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
DATABASE='<DATABASENAME>'
PASSWORD='<PASSWORD>'
USER='<USER>@<RESOURCE>'
HOST='<HOST>.postgres.database.azure.com'
#DATABASE_URL://USER:PASSWORD@HOST:PORT/NAME
DATABASE_URL=postgres://djangonaut:djangonaut@localhost:5432/djangonaut-space
SECRET_KEY=<SECRETKEY>
ENVIRONMENT='production'
RECAPTCHA_PUBLIC_KEY='dummy_value'
Expand Down
2 changes: 1 addition & 1 deletion .env.template.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DATABASE='djangonaut-space'
DATABASE_URL=postgres://djangonaut:djangonaut@localhost:5432/djangonaut-space
SECRET_KEY=<SECRETKEY>
RECAPTCHA_PUBLIC_KEY='dummy_value'
RECAPTCHA_PRIVATE_KEY='dummy_value'
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/develop_djangonaut_space.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ name: Staging build and deploy Python app to Azure Web App - djangonaut-space
env:
AZURE_WEBAPP_NAME: staging-djangonaut-space # set this to the name of your Azure Web App
AZURE_WEBAPP_PACKAGE_PATH: '.'
PYTHON_VERSION: '3.9' # set this to the Python version to use
NODE_VERSION: '17.6.0'
PYTHON_VERSION: '3.11' # set this to the Python version to use
NODE_VERSION: '20.11.1'

on:
push:
Expand All @@ -38,13 +38,10 @@ jobs:
APPINSIGHTS_INSTRUMENTATIONKEY: ${{ secrets.STAGING_APPINSIGHTS_INSTRUMENTATIONKEY }}
APPLICATIONINSIGHTSAGENT_EXTENSION_ENABLED: 'true'
DEBUG: 'True'
HOST: ${{ secrets.HOST_ADDON }}
PASSWORD: ${{ secrets.PASSWORD_ADDON }}
RECAPTCHA_PRIVATE_KEY: ${{ secrets.RECAPTCHA_PRIVATE_KEY }}
RECAPTCHA_PUBLIC_KEY: ${{ secrets.RECAPTCHA_PUBLIC_KEY }}
SCM_DO_BUILD_DURING_DEPLOYMENT: 'true'
SECRET_KEY: ${{ secrets.STAGING_SECRET_KEY }}
USER: ${{ secrets.USER_ADDON }}
WEBSITE_HTTPLOGGING_RETENTION_DAYS: '7'
AZURE_ACCOUNT_NAME: ${{ secrets.AZURE_ACCOUNT_NAME }}
AZURE_ACCOUNT_KEY: ${{ secrets.AZURE_ACCOUNT_KEY }}
Expand All @@ -56,6 +53,8 @@ jobs:
POST_BUILD_COMMAND: 'scripts/postbuild.sh'
# Allow install node to support tailwind
ENABLE_MULTIPLATFORM_BUILD: 'true'
# Used for running `manage.py migrate` in postbuild.sh
DATABASE_URL: ${{ secrets.STAGING_DATABASE_URL }}
environment: staging-djangonaut-space
runs-on: ubuntu-latest

Expand All @@ -70,7 +69,7 @@ jobs:

- name: Set up Node version
uses: actions/setup-node@v4
with:
with:
node-version: ${{ env.NODE_VERSION }}

- name: Test NodeJS
Expand All @@ -88,7 +87,7 @@ jobs:
# Optional: Add step to run tests here (PyTest, Django test suites, etc.)

- name: Building web app
uses: azure/appservice-build@v2
uses: azure/appservice-build@v3
- name: Deploy web App using GH Action azure/webapps-deploy
uses: azure/webapps-deploy@v3
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/main_djangonaut-space.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
env:
AZURE_WEBAPP_NAME: djangonaut-space
AZURE_WEBAPP_PACKAGE_PATH: '.'
PYTHON_VERSION: '3.11'

jobs:
build:
Expand All @@ -23,13 +24,10 @@ jobs:
APPINSIGHTS_INSTRUMENTATIONKEY: ${{ secrets.APPINSIGHTS_INSTRUMENTATIONKEY }}
APPLICATIONINSIGHTSAGENT_EXTENSION_ENABLED: 'true'
DEBUG: False
HOST: ${{ secrets.HOST }}
PASSWORD: ${{ secrets.PASSWORD }}
RECAPTCHA_PRIVATE_KEY: ${{ secrets.RECAPTCHA_PRIVATE_KEY }}
RECAPTCHA_PUBLIC_KEY: ${{ secrets.RECAPTCHA_PUBLIC_KEY }}
SCM_DO_BUILD_DURING_DEPLOYMENT: 'true'
SECRET_KEY: ${{ secrets.SECRET_KEY }}
USER: ${{ secrets.USER }}
WEBSITE_HTTPLOGGING_RETENTION_DAYS: '7'
AZURE_ACCOUNT_NAME: ${{ secrets.AZURE_ACCOUNT_NAME }}
AZURE_ACCOUNT_KEY: ${{ secrets.AZURE_ACCOUNT_KEY }}
Expand All @@ -39,6 +37,8 @@ jobs:
POST_BUILD_COMMAND: 'scripts/postbuild.sh'
# Allow install node to support tailwind
ENABLE_MULTIPLATFORM_BUILD: 'true'
# Used for running `manage.py migrate` in postbuild.sh
DATABASE_URL: ${{ secrets.DATABASE_URL }}
environment: prod-djangonaut-space
runs-on: ubuntu-latest

Expand All @@ -48,7 +48,7 @@ jobs:
- name: Set up Python version
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
run: |
Expand All @@ -58,7 +58,7 @@ jobs:
printenv -0
- name: Building web app
uses: azure/appservice-build@v2
uses: azure/appservice-build@v3
- name: Deploy web App using GH Action azure/webapps-deploy
uses: azure/webapps-deploy@v3
with:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ jobs:
env:
ENVIRONMENT: 'test'
DJANGO_SETTINGS_MODULE: 'indymeet.settings.test'
HOST: "localhost"
USER: "djangonaut"
PASSWORD: "djangonaut"
DATABASE_URL: "postgres://djangonaut:djangonaut@localhost:5432/djangonaut-space"
DEBUG: False
SECRET_KEY: "hunter2"
RECAPTCHA_PUBLIC_KEY: "dummy_value"
Expand All @@ -38,7 +36,7 @@ jobs:
- name: Set up Python version
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.11'

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ This section should list any major frameworks/libraries used to bootstrap your p
### Prerequisites

This is an example of how to list things you need to use the software and how to install them.
* Python version 3.10.5
* Python version 3.11

### Installation

Expand Down
30 changes: 27 additions & 3 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

from django.contrib import admin

from .models import Event
from .models import Session
from .models import SessionMembership
from .models import Event, Question, Session, SessionMembership, Survey


@admin.register(Event)
Expand All @@ -28,3 +26,29 @@ class SessionMembershipAdmin(admin.ModelAdmin):
class SessionAdmin(admin.ModelAdmin):
model = Session
inlines = [SessionMembershipInline]


class QuestionInline(admin.StackedInline):
model = Question
extra = 0
fields = (
"label",
"type_field",
"choices",
"help_text",
"required",
"ordering",
)


@admin.register(Survey)
class SurveyAdmin(admin.ModelAdmin):
model = Survey
inlines = [QuestionInline]
fields = (
"name",
"description",
"editable",
"deletable",
"session",
)
1 change: 0 additions & 1 deletion home/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from wagtail.core import blocks
from wagtail.images.blocks import ImageChooserBlock


CODE_LANGUAGE_OPTIONS = (
("Python", "python"),
("Markup", "html"),
Expand Down
6 changes: 6 additions & 0 deletions home/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DATE_INPUT_FORMAT = ["%Y-%m-%d", "%m/%d/%Y", "%m/%d/%y", "%d/%m/%y", "%d/%m/%Y"]

SURVEY_FIELD_VALIDATORS = {
"max_length": {"email": 150, "text": 250, "url": 250},
"min_length": {"text_area": 100, "text": 3},
}
45 changes: 44 additions & 1 deletion home/factories.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import factory
from home.models import Event, Session

from accounts.factories import UserFactory
from home.models import (
Event,
Question,
Session,
Survey,
TypeField,
UserQuestionResponse,
UserSurveyResponse,
)


class EventFactory(factory.django.DjangoModelFactory):
Expand All @@ -26,3 +36,36 @@ class Meta:
application_start_date = factory.Faker("date")
application_end_date = factory.Faker("date")
application_url = factory.Sequence(lambda n: "https://apply.session%d.com" % n)


class SurveyFactory(factory.django.DjangoModelFactory):
class Meta:
model = Survey

name = factory.Sequence(lambda n: "Survey %d" % n)


class QuestionFactory(factory.django.DjangoModelFactory):
class Meta:
model = Question

survey = factory.SubFactory(SurveyFactory)
label = factory.Sequence(lambda n: "Label %d" % n)
type_field = TypeField.TEXT


class UserSurveyResponseFactory(factory.django.DjangoModelFactory):
class Meta:
model = UserSurveyResponse

user = factory.SubFactory(UserFactory)
survey = factory.SubFactory(SurveyFactory)


class UserQuestionResponseFactory(factory.django.DjangoModelFactory):
class Meta:
model = UserQuestionResponse

question = factory.SubFactory(QuestionFactory)
value = factory.Sequence(lambda n: "Answer %d" % n)
user_survey_response = factory.SubFactory(UserSurveyResponseFactory)
Loading

0 comments on commit 37df9b0

Please sign in to comment.