initial commit
This commit is contained in:
0
backend/hub/__init__.py
Normal file
0
backend/hub/__init__.py
Normal file
BIN
backend/hub/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
backend/hub/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
backend/hub/__pycache__/admin.cpython-312.pyc
Normal file
BIN
backend/hub/__pycache__/admin.cpython-312.pyc
Normal file
Binary file not shown.
BIN
backend/hub/__pycache__/apps.cpython-312.pyc
Normal file
BIN
backend/hub/__pycache__/apps.cpython-312.pyc
Normal file
Binary file not shown.
BIN
backend/hub/__pycache__/models.cpython-312.pyc
Normal file
BIN
backend/hub/__pycache__/models.cpython-312.pyc
Normal file
Binary file not shown.
8
backend/hub/admin.py
Normal file
8
backend/hub/admin.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from django.contrib import admin
|
||||
from .models import Hub, HubMembership, Message, HubChannel
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(Hub)
|
||||
admin.site.register(HubMembership)
|
||||
admin.site.register(Message)
|
||||
admin.site.register(HubChannel)
|
||||
6
backend/hub/apps.py
Normal file
6
backend/hub/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class HubConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'hub'
|
||||
32
backend/hub/migrations/0001_initial.py
Normal file
32
backend/hub/migrations/0001_initial.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# Generated by Django 5.1.4 on 2024-12-08 23:51
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Hub',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=100)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='HubMembership',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('hub', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hub.hub')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.1.4 on 2024-12-09 00:14
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hub', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name='hubmembership',
|
||||
unique_together={('user', 'hub')},
|
||||
),
|
||||
]
|
||||
26
backend/hub/migrations/0003_message.py
Normal file
26
backend/hub/migrations/0003_message.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# Generated by Django 5.1.4 on 2024-12-09 18:12
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hub', '0002_alter_hubmembership_unique_together'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Message',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('content', models.TextField()),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('hub', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='messages', to='hub.hub')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='messages', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
||||
26
backend/hub/migrations/0004_remove_message_hub_hubchannel.py
Normal file
26
backend/hub/migrations/0004_remove_message_hub_hubchannel.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# Generated by Django 5.1.4 on 2024-12-14 23:07
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hub', '0003_message'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='message',
|
||||
name='hub',
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='HubChannel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('hub', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hub.hub')),
|
||||
],
|
||||
),
|
||||
]
|
||||
17
backend/hub/migrations/0005_remove_hubchannel_hub.py
Normal file
17
backend/hub/migrations/0005_remove_hubchannel_hub.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Generated by Django 5.1.4 on 2024-12-15 01:47
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hub', '0004_remove_message_hub_hubchannel'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='hubchannel',
|
||||
name='hub',
|
||||
),
|
||||
]
|
||||
20
backend/hub/migrations/0006_hubchannel_hub.py
Normal file
20
backend/hub/migrations/0006_hubchannel_hub.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Generated by Django 5.1.4 on 2024-12-15 01:48
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hub', '0005_remove_hubchannel_hub'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='hubchannel',
|
||||
name='hub',
|
||||
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='hub.hub'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
20
backend/hub/migrations/0007_message_hubchannels.py
Normal file
20
backend/hub/migrations/0007_message_hubchannels.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Generated by Django 5.1.4 on 2024-12-15 01:49
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hub', '0006_hubchannel_hub'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='message',
|
||||
name='hubChannels',
|
||||
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='messages', to='hub.hubchannel'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.1.4 on 2024-12-16 21:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hub', '0007_message_hubchannels'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='message',
|
||||
name='image',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='message_images/'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='message',
|
||||
name='content',
|
||||
field=models.TextField(blank=True),
|
||||
),
|
||||
]
|
||||
0
backend/hub/migrations/__init__.py
Normal file
0
backend/hub/migrations/__init__.py
Normal file
BIN
backend/hub/migrations/__pycache__/0001_initial.cpython-312.pyc
Normal file
BIN
backend/hub/migrations/__pycache__/0001_initial.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/hub/migrations/__pycache__/0003_message.cpython-312.pyc
Normal file
BIN
backend/hub/migrations/__pycache__/0003_message.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/hub/migrations/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
backend/hub/migrations/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
37
backend/hub/models.py
Normal file
37
backend/hub/models.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
# Create your models here.
|
||||
class Hub(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
|
||||
def __str__(self):
|
||||
return self.name + " hub"
|
||||
|
||||
class HubMembership(models.Model):
|
||||
hub = models.ForeignKey(Hub, on_delete=models.CASCADE)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.user} + {self.hub}"
|
||||
|
||||
class Meta:
|
||||
unique_together = ('user', 'hub')
|
||||
|
||||
class HubChannel(models.Model):
|
||||
hub = models.ForeignKey(Hub, on_delete=models.CASCADE)
|
||||
name = models.CharField(max_length=100)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} + {self.hub}"
|
||||
|
||||
class Message(models.Model):
|
||||
hubChannels = models.ForeignKey(HubChannel, on_delete=models.CASCADE, related_name='messages')
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='messages')
|
||||
content = models.TextField(blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
image = models.ImageField(upload_to='message_images/', blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.user.username}: {self.content[:50]}..."
|
||||
3
backend/hub/tests.py
Normal file
3
backend/hub/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
backend/hub/views.py
Normal file
3
backend/hub/views.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user