Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Contributing

Thank you for help improving Place. All kinds of contributions are welcome.

Please submit an Issue or even better a PR and We'll review :)
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.13-slim-bookworm AS builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Change the working directory to the `app` directory
WORKDIR /opt
WORKDIR /app

# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
Expand All @@ -11,19 +11,25 @@ RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-editable --no-dev --group prod

# Copy the project into the intermediate image
ADD ./place /opt
ADD ./place /app

FROM python:3.13-slim-bookworm

WORKDIR /opt

# Copy the environment, but not the source code
COPY --from=builder --chown=opt:opt /opt /opt
COPY --from=builder --chown=app:app /app /app

EXPOSE 8000
WORKDIR /app

# entrypoint, must be executable file chmod +x entrypoint.sh
COPY entrypoint.sh .

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PATH="/app/.venv/bin:$PATH"

# Expose port 8000
EXPOSE 8000

# Run the application
ENTRYPOINT ["./entrypoint.sh"]
152 changes: 96 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,107 @@

An event application for Cameroon that helps users find events based on their interests, location, and availability.

## Deployment Guide
## Table of Contents
* **[Installation](#installation)**
* [uv](#uv)
* [Pip](#pip)
* [Docker](#docker)
* [Contributing](#contributing)
* [Support](#support)
* [License](#license)

### Prerequisites
## 📖 Installation

- **Python 3.11+** ([Download](https://python.org))
Place can be installed via Pip or Docker. To start, clone the repo to your local computer and change into the proper directory.

### 🧰 Prerequisites

- **Python 3.13+** ([Download](https://python.org))
- **Docker** (Optional) ([Install Docker](https://docs.docker.com/get-started/get-docker/))
- **UV** (Optional, for fast Python management) ([Install UV](https://docs.astral.sh/uv/getting-started/installation/))

### Setup Instructions

**Install Dependencies**
- **With Python:**
```sh
pip install .
```
- **With UV (Faster):** No needed
- **With Docker:** No needed

**Setup**
- **With Python:**
```sh
python place/manage.py makemigrations
python place/manage.py migrate
```
- **With UV (Faster):**
```sh
uv run place/manage.py makemigrations
uv run place/manage.py migrate
```
- **With Docker:** No needed

**Run the App**
- **With Python:**
```sh
python place/manage.py runserver
```
- **With UV (Faster):**
```sh
uv run place/manage.py runserver
```
- **With Docker:**
```sh
docker compose up -d
```

**Loading the dummy data**
- **With Python:**
```sh
python place/manage.py shell -c "import core.dummy_data"
```
- **With UV (Faster):**
```sh
uv run place/manage.py shell -c "import core.dummy_data"
```
- **With Docker:**
```sh
docker compose exec place-web ./entrypoint.sh shell -c \"import core.dummy_data\"
```
- **UV** (Optional, for fast Python package management) ([Install UV](https://docs.astral.sh/uv/getting-started/installation/))

### Install Dependencies

- With Pip:

```sh
pip install .
```

- With uv:

```sh
uv sync
```

- With Docker: Not needed

### Setup

- With Python:

```sh
python place/manage.py migrate
```

- With uv:

```sh
uv run place/manage.py migrate
```

- With Docker: Not needed

### Run the App

- With Python:

```sh
python place/manage.py runserver
```

- With uv:

```sh
uv run place/manage.py runserver
```

- With Docker:

```sh
docker compose up -d
```

### Load the dummy data

- With Python:

```sh
python place/manage.py shell -c "import core.dummy_data"
```

- With uv:

```sh
uv run place/manage.py shell -c "import core.dummy_data"
```

- With Docker:

```sh
docker compose exec place ./entrypoint.sh shell -c \"import core.dummy_data\"
```

**Access the webapp**
Open your browser at: [http://127.0.0.1:8000](http://127.0.0.1:8000)
Open your browser at: [http://127.0.0.1:8000](http://127.0.0.1:8000) or [http://127.0.0.1:8000/admin](http://127.0.0.1:8000/admin) for the admin

## 🤝 Contributing

Contributions, issues and feature requests are welcome! See [CONTRIBUTING.md](https://github.com/wsvincent/lithium/blob/master/CONTRIBUTING.md).

## ⭐️ Support

Give a ⭐️ if this project helped you!

## License

Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ services:
image: place
build: .
volumes:
- static_data:/opt/staticfiles
- static_data:/app/staticfiles
place-nginx:
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- static_data:/opt/staticfiles:ro
- static_data:/app/staticfiles:ro
ports:
- 8000:80

volumes:
static_data:
static_data:
4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -ex
.venv/bin/python manage.py migrate --noinput

if [ -z "$@" ]; then
gunicorn place.asgi:application -k uvicorn_worker.UvicornWorker -b 0.0.0.0:8000
gunicorn place.asgi:application -k uvicorn_worker.UvicornWorker -b :8000 -w 2
else
eval .venv/bin/python manage.py $@
fi
fi
Empty file added place/accounts/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions place/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin

from .forms import CustomUserCreationForm, CustomUserChangeForm
from .models import CustomUser


class CustomUserAdmin(UserAdmin):
add_form = CustomUserCreationForm
form = CustomUserChangeForm
model = CustomUser
list_display = [
"email",
"username",
"is_staff",
"is_active",
]


admin.site.register(CustomUser, CustomUserAdmin)
6 changes: 6 additions & 0 deletions place/accounts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AccountsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "accounts"
20 changes: 20 additions & 0 deletions place/accounts/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.contrib.auth.forms import AdminUserCreationForm, UserChangeForm
from .models import CustomUser


class CustomUserCreationForm(AdminUserCreationForm):
class Meta:
model = CustomUser
fields = (
"email",
"username",
)


class CustomUserChangeForm(UserChangeForm):
class Meta:
model = CustomUser
fields = (
"email",
"username",
)
Empty file.
9 changes: 9 additions & 0 deletions place/accounts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.contrib.auth.models import AbstractUser
# from django.db import models


class CustomUser(AbstractUser):
pass

def __str__(self):
return self.email
3 changes: 3 additions & 0 deletions place/accounts/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions place/accounts/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# from django.shortcuts import render

# Create your views here.
1 change: 0 additions & 1 deletion place/core/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.db import models
from django.utils import timezone

from django.shortcuts import reverse


Expand Down
4 changes: 1 addition & 3 deletions place/core/templates/core/event.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<div class="card event-card h-100">
<img src="https://bulma.io/assets/images/placeholders/128x128.png"
class="card-img-top"
alt="Event">
{% if event.image %}<img src="{{ event.image.url }}" class="card-img-top" alt="Event">{% endif %}
<div class="card-body">
<span class="badge bg-success mb-2">{{ event.get_location_type_display }}</span>
<h5 class="card-title">{{ event.title }}</h5>
Expand Down
2 changes: 1 addition & 1 deletion place/core/templates/core/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "core/base.html" %}
{% extends "base.html" %}
{% load humanize %}
{% block hero %}
<!-- Hero Section with Search -->
Expand Down
2 changes: 1 addition & 1 deletion place/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@


urlpatterns = [
path("", views.index),
path("", views.index, name="home"),
path("htmx/events", views.htmx_events, name="htmx-events"),
]
Loading