-
Notifications
You must be signed in to change notification settings - Fork 1
Initial models creation #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: nightly
Are you sure you want to change the base?
Changes from all commits
18a52f2
a37f9c8
eba413f
598385b
15f518d
fc44276
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,8 @@ | ||
| """FriendsWave URL Configuration | ||
|
|
||
| The `urlpatterns` list routes URLs to views. For more information please see: | ||
| https://docs.djangoproject.com/en/3.2/topics/http/urls/ | ||
| Examples: | ||
| Function views | ||
| 1. Add an import: from my_app import views | ||
| 2. Add a URL to urlpatterns: path('', views.home, name='home') | ||
| Class-based views | ||
| 1. Add an import: from other_app.views import Home | ||
| 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') | ||
| Including another URLconf | ||
| 1. Import the include() function: from django.urls import include, path | ||
| 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) | ||
| """ | ||
| from django.contrib import admin | ||
| from django.urls import path | ||
| from django.conf import settings | ||
| from django.conf.urls.static import static | ||
|
|
||
| urlpatterns = [ | ||
| path('admin/', admin.site.urls), | ||
| ] | ||
| ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.contrib import admin | ||
|
|
||
| # Register your models here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class CommentmoduleConfig(AppConfig): | ||
| default_auto_field = 'django.db.models.BigAutoField' | ||
| name = 'commentModule' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| from django.db import models | ||
| from social.models import Profil | ||
| from postModule.models import Post | ||
| from django.utils import timezone | ||
| # Create your models here. | ||
|
|
||
|
|
||
| """ | ||
| model Content | ||
| """ | ||
| class Content(models.Model): | ||
| Profil = models.ForeignKey(Profil, on_delete=models.CASCADE, related_name="creator") | ||
| shares = models.ManyToManyField(Profil, through='Share') | ||
| likes = models.ManyToManyField(Profil, through='Like') | ||
| content = models.TextField(max_length=1000) | ||
| media = models.FileField(upload_to='uploads/%Y/%m/%d/', null=True, blank=True) | ||
| created_at = models.DateTimeField(default=timezone.now, editable=False) | ||
| update_at = models.DateTimeField(auto_now=True) | ||
|
|
||
| class Meta: | ||
| ordering = ['created_at'] | ||
| abstract = True | ||
| verbose_name = 'content' | ||
| verbose_plural_name = "contents" | ||
|
|
||
| def __str__(self): | ||
| return self.content | ||
|
|
||
|
|
||
| """ | ||
| model Comment | ||
| """ | ||
| class Comment(Content): | ||
| post = models.ForeignKey(Post, on_delete=models.CASCADE) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.test import TestCase | ||
|
|
||
| # Create your tests here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.shortcuts import render | ||
|
|
||
| # Create your views here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.contrib import admin | ||
|
|
||
| # Register your models here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class GroupmoduleConfig(AppConfig): | ||
| default_auto_field = 'django.db.models.BigAutoField' | ||
| name = 'groupModule' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| from django.db import models | ||
| from social.models import Profil | ||
| from django.utils import timezone | ||
|
|
||
| # Create your models here. | ||
|
|
||
|
|
||
| """ | ||
| model Group | ||
| """ | ||
| class Group(models.Model): | ||
| VISIBILITY = ( | ||
| ('PUG', 'Public Group'), | ||
| ('PRG', 'Private Group') | ||
| ) | ||
|
|
||
| members = models.ManyToManyField(Profil, through='Member') | ||
| name = models.CharField(max_length=100) | ||
| description = models.TextField(max_length=100) | ||
| visibilty = models.CharField(max_length=100, choices=VISIBILITY) | ||
| link = models.CharField(max_length=100) | ||
| created_at = models.DateTimeField(default=timezone.now, editable=False) | ||
| update_at = models.DateTimeField(auto_now=True) | ||
|
|
||
| class Meta: | ||
| ordering = ['created_at', 'name'] | ||
| verbose_name = "Group" | ||
| verbose_plural_name = "Groups" | ||
|
|
||
| def __str__(self): | ||
| return self.name | ||
|
|
||
|
|
||
|
|
||
| """ | ||
| model Member | ||
| """ | ||
| class Member(models.Model): | ||
| group = models.ForeignKey(Group, on_delete=models.CASCADE) | ||
| profil = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
| is_admin = models.BooleanField(default=False) | ||
| is_owner = models.BooleanField(default=False) | ||
| date_joined = models.DateTimeField(default=timezone.now, editable=False) | ||
| end= models.DateTimeField(null=True) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.test import TestCase | ||
|
|
||
| # Create your tests here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.shortcuts import render | ||
|
|
||
| # Create your views here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.contrib import admin | ||
|
|
||
| # Register your models here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class PostmoduleConfig(AppConfig): | ||
| default_auto_field = 'django.db.models.BigAutoField' | ||
| name = 'postModule' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| from django.db import models | ||
| from social.models import Profil, Topic | ||
| from django.utils import timezone | ||
|
|
||
| # Create your models here. | ||
|
|
||
| """ | ||
| model Content | ||
| """ | ||
| class Content(models.Model): | ||
| Profil = models.ForeignKey(Profil, on_delete=models.CASCADE, related_name="creator") | ||
| shares = models.ManyToManyField(Profil, through='Share') | ||
| likes = models.ManyToManyField(Profil, through='Like') | ||
| content = models.TextField(max_length=1000) | ||
| media = models.FileField(upload_to='uploads/%Y/%m/%d/', null=True, blank=True) | ||
| created_at = models.DateTimeField(default=timezone.now, editable=False) | ||
| update_at = models.DateTimeField(auto_now=True) | ||
|
|
||
| class Meta: | ||
| ordering = ['created_at'] | ||
| abstract = True | ||
| verbose_name = 'content' | ||
| verbose_plural_name = "contents" | ||
|
|
||
| def __str__(self): | ||
| return self.content | ||
|
|
||
|
|
||
| """ | ||
| model Post | ||
| """ | ||
| class Post(Content): | ||
| topic = models.ForeignKey(Topic, on_delete=models.CASCADE) | ||
|
|
||
|
|
||
|
|
||
| """ | ||
| model Like | ||
| """ | ||
| class Like(models.Model): | ||
| profil = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
| content = models.ForeignKey(Content, on_delete=models.CASCADE) | ||
| created_at = models.DateTimeField(default=timezone.now, editable=False) | ||
| update_at = models.DateTimeField(auto_now=True) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.test import TestCase | ||
|
|
||
| # Create your tests here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.shortcuts import render | ||
|
|
||
| # Create your views here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| asn1crypto==0.24.0 | ||
| backports.entry-points-selectable==1.1.1 | ||
| configparser==4.0.2 | ||
| contextlib2==0.6.0.post1 | ||
| cryptography==2.1.4 | ||
| distlib==0.3.3 | ||
| django-environ==0.4.5 | ||
| duplicity==0.7.17 | ||
| enum34==1.1.6 | ||
| fasteners==0.12.0 | ||
| filelock==3.2.1 | ||
| idna==2.6 | ||
| importlib-metadata==2.1.2 | ||
| importlib-resources==3.3.1 | ||
| ipaddress==1.0.17 | ||
| keyring==10.6.0d | ||
| keyrings.alt==3.0 | ||
| lockfile==0.12.2 | ||
| Markdown==3.1.1 | ||
| monotonic==1.0 | ||
| mysql-connector-python==2.1.6 | ||
| mysql-utilities==1.6.4 | ||
| paramiko==2.0.0 | ||
| pathlib2==2.3.6 | ||
| pexpect==4.2.1 | ||
| platformdirs==2.0.2 | ||
| psycopg2-binary==2.8.6 | ||
| pyasn1==0.4.2 | ||
| pycrypto==2.6.1 | ||
| pygobject==3.26.1 | ||
| pyodbc==4.0.17 | ||
| pysqlite==2.7.0 | ||
| python-decouple==3.5 | ||
| pyxdg==0.25 | ||
| scandir==1.10.0 | ||
| SecretStorage==2.3.1 | ||
| singledispatch==3.7.0 | ||
| six==1.16.0 | ||
| typing==3.10.0.0 | ||
| virtualenv==20.10.0 | ||
| zipp==1.2.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,76 @@ | ||
| from django.db import models | ||
| from django.db import models, utils | ||
| from django.contrib.auth.models import AbstractUser | ||
| from django.utils import timezone | ||
| from topicModule.models import Topic | ||
|
|
||
| # Create your models here. | ||
|
|
||
| """ | ||
| model user extend default user django | ||
| """ | ||
| class User(AbstractUser): | ||
| GENRE = ( | ||
| ('M', 'Masculin'), | ||
| ('F', 'Feminin') | ||
| ) | ||
|
|
||
| first_name = models.CharField(max_length=100) | ||
| last_npassame = models.CharField(max_length=100) | ||
| birth_date = models.DateField(null=True, blank=True) | ||
| genre = models.CharField(max_length=1, choices=GENRE) | ||
| phone_number = models.CharField(max_length=20) | ||
| address = models.CharField(max_length=30, blank=True) | ||
| user_name = models.CharField(max_length=20) | ||
| password = models.CharField(max_length=20) | ||
| created_at = models.DateTimeField(default=timezone.now, editable=False) | ||
| update_at = models.DateTimeField(auto_now=True) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. General |
||
| class Meta: | ||
| ordering = ['created_at', 'genre'] | ||
|
|
||
| def __str__(self): | ||
| return "%s %s" % (self.first_name, self.last_name) | ||
|
|
||
|
|
||
| """ | ||
| model Profil | ||
| """ | ||
| class Profil(models.Models): | ||
| user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="belong") | ||
| follow = models.ManyToManyField('self', through='Friend', related_name="have") | ||
| topics_of_interest = models.ManyToManyField(Topic, through='UserTopic') | ||
| pseudo = models.CharField(max_length=100) | ||
| avatar = models.ImageField(upload_to="static", null=True, blank=True) | ||
| email = models.EmailField(max_length=100) | ||
| is_active = models.BooleanField(default=True) | ||
| created_at = models.DateTimeField(default=timezone.now, editable=False) | ||
| update_at = models.DateTimeField(auto_now=True) | ||
|
|
||
| class Meta: | ||
| ordering = ['created_at'] | ||
| verbose_name = "Profil" | ||
| verbose_plural_name = "Profils" | ||
|
|
||
| def __str__(self): | ||
| return self.pseudo | ||
|
|
||
|
|
||
|
|
||
| """ | ||
| model Friend | ||
| """ | ||
| class Friend(models.Model): | ||
| STATUS = ( | ||
| ('A', 'ACCEPT'), | ||
| ('D', 'DENIE') | ||
| ) | ||
|
|
||
| follower = models.ForeignKey(Profil, on_delete=models.CASCADE, related_name="friends") | ||
| followed = models.ForeignKey(Profil, on_delete=models.CASCADE, related_name="friend") | ||
| status = models.CharField(max_length=1, choices=STATUS) | ||
|
|
||
| class Meta: | ||
| verbose_name = "friend" | ||
| verbose_plural_name = "friends" | ||
|
|
||
| def __str__(self): | ||
| return self.STATUS | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| from django.shortcuts import render | ||
|
|
||
| # Create your views here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.contrib import admin | ||
|
|
||
| # Register your models here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need 2 line between 2 first level code in python (ref PEP 8) https://pep8.org/