Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f4aaa83
set docker for dev databases (from Sheena branch), fix duplicated ur…
anjaniacatus May 4, 2025
b783659
fix the date
anjaniacatus May 5, 2025
ff7bd18
wagtail local configuration
anjaniacatus May 5, 2025
b5525b6
grants app added , commands to treat csv file
anjaniacatus May 5, 2025
a1ef86c
template added , use a verification code for safety check
anjaniacatus May 5, 2025
fd12d1a
prettify the grants status template
anjaniacatus May 5, 2025
fd1d1c1
add grant status ob the main menu
anjaniacatus May 6, 2025
7dbb749
fix layout for grants
anjaniacatus May 6, 2025
0684d4a
making sure that mailjet or console emailing is working
anjaniacatus May 8, 2025
d2a616e
format check
anjaniacatus May 8, 2025
aee5941
add decouple to the package required
anjaniacatus May 9, 2025
96b9fe3
fix header tratement for the csv file
anjaniacatus May 9, 2025
53e8bab
fix : decouple package
anjaniacatus May 10, 2025
201105b
fix : decouple package
anjaniacatus May 10, 2025
3d90986
fix : format
anjaniacatus May 10, 2025
08bc889
fix : format
anjaniacatus May 10, 2025
066f758
add command to import grants file
anjaniacatus May 10, 2025
6c11434
add revert option to add grant data in the databases
anjaniacatus May 10, 2025
e9dc453
add some test
anjaniacatus May 11, 2025
4a48819
separate logging configuration
anjaniacatus May 11, 2025
d20fde4
.
anjaniacatus May 11, 2025
cb9b1c4
remove unused file
anjaniacatus May 11, 2025
1896b5a
remove profession, country and city of travel
anjaniacatus May 11, 2025
b62f9b8
ignore dev_db conf on remote
anjaniacatus May 11, 2025
4c68a1d
fix test
anjaniacatus May 11, 2025
68865c0
add some package for testing
anjaniacatus May 11, 2025
8dcb61c
cleanup dev db
anjaniacatus May 12, 2025
a9b4d05
ruff check
anjaniacatus May 12, 2025
5687dfb
readd redondant url for wagtail
anjaniacatus May 12, 2025
e5b7927
add some test for sendinf email
anjaniacatus May 12, 2025
6090b7c
adjust workflow
anjaniacatus May 12, 2025
7e00974
.
anjaniacatus May 12, 2025
4fad492
fix failing test on the Ci
anjaniacatus May 12, 2025
f5202f5
debug test ci
anjaniacatus May 12, 2025
5a520d4
debug test ci
anjaniacatus May 12, 2025
d108edc
debug test ci : API mailjet Exception
anjaniacatus May 12, 2025
0391d5f
remove debugging print
anjaniacatus May 12, 2025
6a83859
passing email value
anjaniacatus May 12, 2025
a15f42b
fix : traiting total amount and dudget details
anjaniacatus May 12, 2025
f51e75a
fix some details
anjaniacatus May 12, 2025
6e334a4
do mot use decouple, for consistency reason
anjaniacatus May 13, 2025
711349d
remove redondant test
anjaniacatus May 14, 2025
cda1e5a
covering grants code to 100%
anjaniacatus May 14, 2025
4b15eb9
Merge branch 'djangocon:main' into check_grant_status_feat
anjaniacatus May 14, 2025
58a9ff8
fix: prevent email enumeration
theShinigami May 22, 2025
fe76eef
refactor: put email template in separate directory
theShinigami May 22, 2025
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
6 changes: 5 additions & 1 deletion .env_example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ export DATABASE_NAME=""
export DATABASE_USER=""
export DATABASE_PASSWORD=""
export DATABASE_HOST="localhost"
export DATABASE_PORT="5432"
export DATABASE_PORT="5432"
export MAILJET_SECRET_KEY=""
export MAILJET_API_KEY=""
export DEFAULT_FROM_EMAIL="mailjet@djangocon.africa"
export DJANGO_ENV=development
9 changes: 5 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Generate tailwind css
- name: Generate tailwind css
run: |
npm i
npm i
npm run tailwind

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
- name: Generate Report
run: |
pip install -r requirements.txt
python manage.py collectstatic
pip install coverage pytest pytest-django
python manage.py collectstatic --noinput
coverage run -m pytest
coverage xml
env:
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ eggs/
lib/
lib64/
parts/
media/
sdist/
var/
wheels/
Expand Down Expand Up @@ -168,7 +169,7 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/


dev_db/
.DS_Store
.environment
*/__pycache__/
Expand All @@ -181,4 +182,4 @@ cython_debug/

node_modules/
.vscode/settings.json
.ruff_cache/
.ruff_cache/
71 changes: 50 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# 2025.djangocon.africa
Website for DjangoCon Africa 2025

## Installation
## Installation

To get up and running do the following:


1. Create a virtual environment.

```
python3.12 -m venv venv
python3.12 -m venv venv
```

Of course there are many ways to make a virtual environment. We are following the simplest method. If you like to use a different thing then go for it.

2. Install the requirements

Activate your virtual env
Activate your virtual env

```
source venv/bin/activate
source venv/bin/activate
```

Then install the requirements:
Expand All @@ -31,42 +31,58 @@ pip install -r requirements.txt
3. Install npm dependencies

```
npm install
npm install
```

## Running the application

1. Get the development database up and running:

See: dev_db/README.md

Remember to run the migrations!
## Running the application on development

1. set the database locally as you like. using docker is the easiet way.
those are some configuration sample :

dev_db/docker-compose.yaml
services:
postgres:
image: postgres:12
environment:
- POSTGRES_USER=""
- POSTGRES_PASSWORD=""
- POSTGRES_DB=db
volumes:
- ./gitignore/postgresql:/var/lib/postgresql/data
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
ports:
- "5432:5432"%

docker-entrypoint-initdb.d/create-db-test.sql :
CREATE DATABASE test_db;
grant all privileges on database test_db to pguser;
-- ALTER USER user WITH SUPERUSER;%

2. Run the server

Before using the runserver command, you need to load up some environmental variables. `.env_example` has some sensible defaults that just work in a dev environment:
Before using the runserver command, you need to load up some environmental variables. `.env_example` has some sensible defaults that just work in a dev environment:

```
source .env_example
python manage.py runserver
```
```
source .env_example
python manage.py runserver
```


## Working with tailwind
## Working with tailwind

You can learn about tailwind [here](https://tailwindcss.com/docs/installation). It is installed in this project using the standard "Tailwind CLI" installation.

The Tailwind CLI is used to build a css file. The build process takes in a few inputs:

1. HTML files: It will look at what tailwind classes you are referencing inside your html files. The final built css file will contain only those css classes that are actually being used.
1. HTML files: It will look at what tailwind classes you are referencing inside your html files. The final built css file will contain only those css classes that are actually being used.

2. An input CSS file. In our case we are using `website/static/src/tailwind_input.css`. This file contains any extra classes or default styles.

3. `tailwind.config.js`. This file contains exra configuration. For example if you want to create new colours or define a primary colour or anything like that it will go in there.

The output of the tailwind build is: `website/static/dist/tailwind_final.css`. You can see that we reference this file in our base template, `website/templates/website/_base.html`

### Building the tailwind css file
### Building the tailwind css file

There are 2 commands you can use:

Expand All @@ -91,4 +107,17 @@ Django internationalisation has been enabled for this website and we support Eng
3. For paragraphs, use the `{% blocktranslate %} A paragraph of text {% endblocktranslate %}`. The `{% blocktranslate %}` tag does not support other tags such as `{% static %}` inside it so make sure to close it before other template tags and then open another one. However is supports variable tags such as `{{ number }}` inside it.
4. To generate messages for translations, use the `django-admin makemessages -l fr` and all the files with translate tags will be added to `locale/fr/LC_MESSAGES/django.po`. This is the file translators should edit to support translation into French.
5. To compile messages use the `django-admin compilemessages` command. For more information on Django translations read the Django documentation
https://docs.djangoproject.com/en/5.1/topics/i18n/translation/.
https://docs.djangoproject.com/en/5.1/topics/i18n/translation/.

## wagtail configuration
We use wagtail for to manage articles :
1. Local Configuration : ... (to be added)

## Steps for charging grant application from csv file
1. After exporting the google sheets grants application as a csv, rename the header with following names:
Timestamp,Column1,FullName,Email,Profession,CountryOrigin,CityTravelingFrom,YourNeed,AboutYourself,TypeofGrant,Budget

2. Upload the csv file in /media/
3. Use the command `python manage.py preprocess /media/grants.csv media/grants_treated.csv`
4. After content verification, use the command `python manage.py import_file_grants media/grants_treated.csv` to record data to the databases
5. To revert in case of error . use the command `python manage.py import_file_grants media/grants_treated --revert`
21 changes: 20 additions & 1 deletion core/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"allauth.account",
"sponsors",
"news",
"grants",

# wagtail
'wagtail.contrib.forms',
Expand Down Expand Up @@ -182,6 +183,21 @@

CRISPY_TEMPLATE_PACK = "tailwind"

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'': {
'handlers': ['console'],
'level': 'INFO',
},
},
}
Comment on lines +186 to +200
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's better to move the LOGGING configuration to the appropriate environment specific settings rather than adding it to the base settings.


# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
Expand Down Expand Up @@ -230,4 +246,7 @@
# WAGTAIL SETTINGS
WAGTAIL_SITE_NAME = 'DjangoCon Africa'
WAGTAILADMIN_BASE_URL = "https://2025.djangocon.africa/"
UZA_PUBLIC_API_KEY = os.environ.get("UZA_PUBLIC_API_KEY") # noqa: F405
UZA_PUBLIC_API_KEY = os.environ.get("UZA_PUBLIC_API_KEY") # noqa: F405
# remove wagtail warning
# URLField : RemovedInDjango60Warning
FORMS_URLFIELD_ASSUME_HTTPS = True
61 changes: 58 additions & 3 deletions core/settings_dev.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .settings_base import * # noqa: F403
import dj_database_url
import os
from .settings_base import * # noqa: F403

SECRET_KEY = "not really a secret"
DEBUG = True
Expand Down Expand Up @@ -37,6 +37,61 @@
)
}

EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
# Email Sending settings
DEFAULT_FROM_EMAIL = os.environ.get("DEFAULT_FROM_EMAIL", "mailjet@djangocon.africa")
DEFAULT_FROM_NAME = "DjangoCon Africa 2025"

# For development (console output)
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

# For production (Mailjet), uncomment this if you want to use Mailjet and don't forget to comment the console backend
# Mailjet configuration
# EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
# MAILJET_API_KEY = os.environ.get('MAILJET_API_KEY')
# MAILJET_API_SECRET = os.environ.get('MAILJET_SECRET_KEY')

EMAIL_FILE_PATH = BASE_DIR / "gitignore/emails" # noqa: F405
FEATURE_FLAGS["USER_LOGIN_REG"] = True # noqa: F405
FEATURE_FLAGS = {"USER_LOGIN_REG": False}
# noqa: F405
WAGTAIL_SITE_NAME = "DjangoCon Africa"
WAGTAILADMIN_BASE_URL = "http://localhost:8000"

# Basic development logging configuration
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
},
'formatters': {
'simple': {
'format': '{levelname} {message}',
'style': '{',
},
},
'loggers': {
'': { # Root logger
'handlers': ['console'],
'level': 'INFO', # Only show INFO and above
'propagate': True,
},
'django': {
'handlers': ['console'],
'level': 'INFO', # Suppress Django DEBUG logs
'propagate': False,
},
'autoreload': {
'handlers': ['console'],
'level': 'WARNING', # Suppress autoreload DEBUG logs
'propagate': False,
},
'wagtail': {
'handlers': ['console'],
'level': 'WARNING', # Suppress Wagtail DEBUG logs
'propagate': False,
},
},
}
15 changes: 6 additions & 9 deletions core/settings_prod.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .settings_base import * # noqa: F403
import dj_database_url
import os

ALLOWED_HOSTS = ["2025.djangocon.africa"]
BASE_URL = "https://2025.djangocon.africa"
Expand All @@ -18,12 +19,8 @@


# email config - to be setted in another feature
EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
EMAIL_FILE_PATH = BASE_DIR / "gitignore/emails" # noqa: F405

# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# EMAIL_HOST = 'smtp.gmail.com'
# EMAIL_USE_TLS = True
# EMAIL_PORT = 587
# EMAIL_HOST_USER = str(os.getenv('EMAIL_USER'))
# EMAIL_HOST_PASSWORD = str(os.getenv('EMAIL_PASSWORD'))
EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
MAILJET_API_KEY = os.environ.get('MAILJET_API_KEY')
MAILJET_API_SECRET = os.environ.get('MAILJET_SECRET_KEY')
DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL', default="hello@djangocon.africa")
DEFAULT_FROM_NAME = 'DjangoCon Africa 2025'
4 changes: 3 additions & 1 deletion core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
path('i18n/', include('django.conf.urls.i18n')),
path('set_language/', set_language, name='set_language'),
path("news/", include("news.urls")),
path('grants/', include('grants.urls')),
]

if settings.DEBUG:
Expand All @@ -44,4 +45,5 @@
path("accounts/", include("allauth.urls")),
path("sponsors/", include("sponsors.urls")),
path("news/", include("news.urls")),
)
path('grants/', include('grants.urls')),
)
Empty file added grants/__init__.py
Empty file.
18 changes: 18 additions & 0 deletions grants/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# grants/admin.py
from django.contrib import admin
from .models import GrantApplication, VerificationCode


@admin.register(GrantApplication)
class GrantApplicationAdmin(admin.ModelAdmin):
list_display = ("full_name", "email", "status", "grant_type", "timestamp")
list_filter = ("status", "grant_type")
search_fields = ("full_name", "email")


@admin.register(VerificationCode)
class VerificationCodeAdmin(admin.ModelAdmin):
list_display = ("email", "code", "created_at", "expires_at")


# Register your models here.
6 changes: 6 additions & 0 deletions grants/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class GrantsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "grants"
Loading