-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add main app in settings * create models and migrations * change privacy enum type to string instead of integer * add logs models * add comment votes model * add logs models and management * add pycache to gitignore
- Loading branch information
Showing
23 changed files
with
1,472 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ | |
api/db.sqlite3 | ||
|
||
frontend/.vscode/ | ||
|
||
api/logs.sqlite3 | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
class DatabaseRouter: | ||
|
||
def db_for_read(self, model, **hints): | ||
if model._meta.app_label == 'neuronaLogs': | ||
return 'logs' | ||
return 'default' | ||
|
||
def db_for_write(self, model, **hints): | ||
if model._meta.app_label == 'neuronaLogs': | ||
return 'logs' | ||
return 'default' | ||
|
||
def allow_relation(self, obj1, obj2, **hints): | ||
return True | ||
|
||
def allow_migrate(self, db, app_label, model_name=None, **hints): | ||
if app_label == 'neuronaLogs': | ||
return db == 'logs' | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Generated by Django 5.0.2 on 2024-02-24 19:39 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Challenges', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('challenge', models.CharField(max_length=100)), | ||
('expires_at', models.DateTimeField()), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='User', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('username', models.CharField(max_length=100, unique=True)), | ||
('email', models.EmailField(max_length=100, unique=True)), | ||
('display_name', models.CharField(max_length=100)), | ||
('passkey_user_id', models.CharField(max_length=100)), | ||
('about', models.TextField(blank=True, max_length=2000)), | ||
('image_url', models.URLField(null=True)), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='RecoveryCodes', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('code', models.CharField(max_length=100)), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='neuronaApp.user')), | ||
], | ||
), | ||
] |
168 changes: 168 additions & 0 deletions
168
api/neuronaApp/migrations/0002_spaces_alter_recoverycodes_user_apikeys_comments_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
# Generated by Django 5.0.2 on 2024-02-24 20:28 | ||
|
||
import django.db.models.deletion | ||
import neuronaApp.models.spaces_models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('neuronaApp', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Spaces', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=100)), | ||
('about', models.TextField(blank=True, max_length=2000)), | ||
('image_url', models.URLField(null=True)), | ||
('privacy', models.IntegerField(choices=[(neuronaApp.models.spaces_models.Privacy['PUBLIC'], 0), (neuronaApp.models.spaces_models.Privacy['PROTECTED'], 1), (neuronaApp.models.spaces_models.Privacy['RESTRICTED'], 2), (neuronaApp.models.spaces_models.Privacy['PRIVATE'], 3)])), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
], | ||
), | ||
migrations.AlterField( | ||
model_name='recoverycodes', | ||
name='user', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='recovery_codes', to='neuronaApp.user'), | ||
), | ||
migrations.CreateModel( | ||
name='ApiKeys', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('key', models.CharField(max_length=256)), | ||
('expires_at', models.DateTimeField()), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='api_keys', to='neuronaApp.user')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='Comments', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('content', models.TextField(max_length=1000)), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='neuronaApp.user')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='CommentsImages', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('image_url', models.URLField()), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('comment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='neuronaApp.comments')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='Posts', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('title', models.CharField(max_length=100)), | ||
('content', models.TextField(max_length=1000)), | ||
('is_archived', models.BooleanField(default=False)), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='posts', to='neuronaApp.user')), | ||
('space', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='posts', to='neuronaApp.spaces')), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name='comments', | ||
name='post', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='neuronaApp.posts'), | ||
), | ||
migrations.CreateModel( | ||
name='PostsImages', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('image_url', models.URLField()), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='neuronaApp.posts')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='PublicKeys', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('key', models.CharField(max_length=5000)), | ||
('credential_id', models.CharField(max_length=100)), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='public_keys', to='neuronaApp.user')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='SpacesAccessRequests', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('space', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='access_requests', to='neuronaApp.spaces')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='access_requests', to='neuronaApp.user')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='SpacesAdmins', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('space', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='admins', to='neuronaApp.spaces')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='admin_of', to='neuronaApp.user')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='SpacesInvitations', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('space', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invitations', to='neuronaApp.spaces')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invitations', to='neuronaApp.user')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='SpacesMembers', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('space', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='members', to='neuronaApp.spaces')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='spaces', to='neuronaApp.user')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='Tags', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=100)), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('space', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tags', to='neuronaApp.spaces')), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name='posts', | ||
name='tag', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='posts', to='neuronaApp.tags'), | ||
), | ||
migrations.CreateModel( | ||
name='Votes', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('is_upvote', models.BooleanField()), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='votes', to='neuronaApp.posts')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='votes', to='neuronaApp.user')), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 5.0.2 on 2024-02-27 21:28 | ||
|
||
import neuronaApp.models.spaces_models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('neuronaApp', '0002_spaces_alter_recoverycodes_user_apikeys_comments_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='spaces', | ||
name='privacy', | ||
field=models.CharField(choices=[(neuronaApp.models.spaces_models.Privacy['PUBLIC'], 'public'), (neuronaApp.models.spaces_models.Privacy['PROTECTED'], 'protected'), (neuronaApp.models.spaces_models.Privacy['RESTRICTED'], 'restricted'), (neuronaApp.models.spaces_models.Privacy['PRIVATE'], 'private')], max_length=100), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 5.0.2 on 2024-02-28 08:40 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('neuronaApp', '0003_alter_spaces_privacy'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CommentsVotes', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('is_upvote', models.BooleanField()), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('comment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='votes', to='neuronaApp.comments')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments_votes', to='neuronaApp.user')), | ||
], | ||
), | ||
] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .user_models import User, Challenges, RecoveryCodes, PublicKeys, ApiKeys | ||
from .posts_models import Posts, PostsImages, Comments, CommentsImages, Votes | ||
from .spaces_models import Spaces, Tags, SpacesMembers, SpacesAdmins, SpacesAccessRequests, SpacesInvitations | ||
|
||
from neuronaLogs.models.logs_managing import * |
Oops, something went wrong.