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 .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=127.0.0.1
EMAIL_PORT=1025 # Mailpit default SMTP port
EMAIL_USE_TLS=False
[email protected]
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
# MyRealEstate
A property management application

## Setup and Installation

### Prerequisites
- Python 3.8+
- Node.js and npm
- Docker (for MinIO)

### Initial Setup

1. Create and activate virtual environment:
```
python
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
Comment on lines +14 to +18
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Remove this superfluous line as it serves no purpose in the instructions

Suggested change
```
python
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```

python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate


1. Install dependencies:
```
pip install -r requirements.txt
```

1. Configure environment variables:
```
Comment on lines +25 to +26
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider referencing the .env.example file in the environment setup section

Since there's a .env.example file in the repository, it would be helpful to instruct users to copy it to .env as part of the setup process

Suggested change
1. Configure environment variables:
```
1. Configure environment variables:
```bash
# Copy the example environment file
cp .env.example .env
# Edit .env file to customize any settings if needed

# No variables needed for now
```

1. Run database migrations:
```
python manage.py migrate
```
### Tailwind CSS Setup

1. Install Tailwind dependencies:
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: The command for installing Tailwind dependencies is missing

Please add the specific command needed to install the Tailwind dependencies


1. Run the development server:
```
python manage.py runserver
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.1.3 on 2024-12-07 14:47

import uuid
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0002_usercompanyaccess_user_companies'),
]

operations = [
migrations.AddField(
model_name='user',
name='email_verification_token',
field=models.UUIDField(default=uuid.uuid4, null=True),
),
migrations.AddField(
model_name='user',
name='email_verified',
field=models.BooleanField(default=False),
),
]
21 changes: 21 additions & 0 deletions myrealestate/accounts/migrations/0004_populate_uuid_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 5.1.3 on 2024-12-07 14:52

import uuid
from django.db import migrations


def gen_uuid(apps, schema_editor):
User = apps.get_model("accounts", "User")
for row in User.objects.all():
row.email_verification_token = uuid.uuid4()
row.save(update_fields=["email_verification_token"])

class Migration(migrations.Migration):

dependencies = [
('accounts', '0003_user_email_verification_token_user_email_verified'),
]

operations = [
migrations.RunPython(gen_uuid, migrations.RunPython.noop),
]
19 changes: 19 additions & 0 deletions myrealestate/accounts/migrations/0005_remove_uuid_null.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.1.3 on 2024-12-07 14:52

import uuid
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0004_populate_uuid_fields'),
]

operations = [
migrations.AlterField(
model_name='user',
name='email_verification_token',
field=models.UUIDField(default=uuid.uuid4, unique=True),
),
]
7 changes: 7 additions & 0 deletions myrealestate/accounts/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import uuid
from django.db import models
from django.contrib.auth.models import AbstractUser, BaseUserManager
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -30,6 +31,12 @@ class User(AbstractUser):
related_name='users',
verbose_name=_('Companies'),
)
email_verified = models.BooleanField(default=False)
email_verification_token = models.UUIDField(unique=True, default=uuid.uuid4)

def generate_verification_token(self):
self.email_verification_token = uuid.uuid4()
self.save()

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['username']
Expand Down
11 changes: 10 additions & 1 deletion myrealestate/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"""

from pathlib import Path
import django.core.mail
import os


# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent.parent
Expand Down Expand Up @@ -198,5 +201,11 @@

MEDIA_URL = f'http://{MINIO_ENDPOINT}/{MINIO_BUCKET_NAME}/'
MEDIA_ROOT = '' # MEDIA_ROOT is not used when using cloud storage
DEFAULT_FILE_STORAGE = 'myrealestate.common.storage.CustomS3Boto3Storage'

EMAIL_BACKEND= os.getenv('EMAIL_BACKEND', 'django.core.mail.backends.smtp.EmailBackend')
EMAIL_HOST= os.getenv('EMAIL_HOST', '127.0.0.1')
EMAIL_PORT= os.getenv('EMAIL_PORT', 1025) # Mailpit default SMTP port
EMAIL_USE_TLS= os.getenv('EMAIL_USE_TLS', False)
DEFAULT_FROM_EMAIL= os.getenv('DEFAULT_FROM_EMAIL', '[email protected]')

DEFAULT_FILE_STORAGE = 'myrealestate.common.storage.CustomS3Boto3Storage'
3 changes: 2 additions & 1 deletion myrealestate/properties/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def form_valid(self, form):
self.object = form.save(commit=False)
self.object.company = self.get_company()
self.object.save()
messages.success(self.request, f"Estate created successfully.")
messages.success(self.request, "Estate created successfully.")

return super(BaseCreateView, self).form_valid(form)


Expand Down
1 change: 0 additions & 1 deletion static/js/utils/patch-handler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// static/js/patch-handler.js
document.addEventListener('DOMContentLoaded', function() {
// Listen for all form submissions
document.addEventListener('submit', async function(e) {
Expand Down
Loading