-
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 1 commit
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,3 +1,90 @@ | ||
| from functools import _Descriptor | ||
| from django.db import models | ||
| from django.db.models.base import Model | ||
| from django.db.models.fields.related import OneToOneField | ||
|
|
||
|
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 Profil(models.Models): | ||
| pseudo = models.CharField(max_length=100) | ||
| image = models.ImageField() | ||
|
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. 1- Make sure static file settings if well configure and Specify specific storage of each static data with functionnality 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. user profile_image intead of image: it's more meaningfull |
||
| user = models.ForeignKey('auth.User', on_delete=models.CASCADE) | ||
| friends = models.ManyToManyField('self', through='Friend') | ||
| topics = models.ManyToManyField('Topic', through='UserTopic') | ||
|
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. topics relates to what? topics created by the user, read by the users, deleted by the user.... Use topics_of_interest: it more meaningfull |
||
| etat = models.BooleanField(default=False) | ||
|
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. etat field is meaning less. active, is_active, profile_is_active are increasingly meaningful |
||
|
|
||
| class Friend(models.Model): | ||
| follower = models.ForeignKey(Profil, OneToOneField = models.CASCADE) | ||
|
Member
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. Specify a related_name on this field to avoid duplication on foreignt key definition by the ORM 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. 1- Wrong setup of the ForeignKey relations using OneToOneField |
||
| followed = models.ForeignKey(Profil, OneToOneField = models.CASCADE) | ||
|
Member
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. Specify a related_name on this field to avoid duplication on foreignt key definition by the ORM |
||
| status = models.BooleanField() | ||
|
|
||
| class Topic(models.Model): | ||
| subject = models.TextField(max_length=100) | ||
| description = models.TextField(max_length=100) | ||
| creator = models.ForeignKey(Profil, on_delete=models.SET_NULL) | ||
|
|
||
| class UserTopic(models.Model): | ||
| profil = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
| topic = models.ForeignKey(Topic, on_delete=models.CASCADE) | ||
| choice_date = models.DateField() | ||
|
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. choice_date vs creation date use a timestamp model mixins to thandle it automatically in created field |
||
| raison = models.TextField(max_length=100) | ||
|
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. "raison": always use English name to refer to field, variables, ... in code |
||
| start_date = models.DateField() | ||
|
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. add field like last_opened for practical reasons |
||
| end_date = models.DateField(null=True) | ||
|
|
||
|
|
||
| class Group(models.Model): | ||
| designation = models.TextField(max_length=100) | ||
|
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. consider replacing designation by name |
||
| _description = models.TextField(max_length=100) | ||
|
Member
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. A field name should not start with 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. remove the underscore on "_description" |
||
| type = models.BooleanField() | ||
|
Member
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.
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. "type" field is meaningless |
||
| created_at = models.DateField() | ||
|
Member
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. The 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. created_at: should be created, and automatically generated by a Timestamp mixin |
||
| members = models.ManyToManyField(Profil, through='Member') | ||
| private_key = models.TextField(max_length=100, null=True) | ||
|
|
||
| class Invitation(models.Model): | ||
|
Member
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. Possible foreign key conflit in this class to handle.
Member
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. There is two |
||
| profil = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
| group = models.ForeignKey(Group, on_delete=models.CASCADE) | ||
| sujbject = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
|
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. ubdate "sujbject" |
||
| created_at = models.DateField() | ||
| etat = models.BooleanField(default=False) | ||
|
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. consider storing etat which might refer to state in a charfield with predefined choice list |
||
|
|
||
| class Member(models.Model): | ||
|
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. consider adding a state boolean on this class to track multiple times sbdy becomes or leaves his group privileges |
||
| 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) | ||
| start_date = models.DateField() | ||
|
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. start_date should be datetime and handled by a model mixin |
||
| end_date = models.DateField(null=True) | ||
|
|
||
| class Content(models.Model): | ||
| Profil = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
|
Member
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. Class attributes don't start like this, refer to the PEP8 coding style. 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. 1- you are using the "Profil" class name to define a field in an other class |
||
| topic = models.ForeignKey(Topic, on_delete=models.CASCADE) | ||
| title = models.TextField() | ||
| content = models.TextField() | ||
|
|
||
| class Meta: | ||
| abstract = True | ||
|
|
||
| class Post(Content): | ||
|
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. 1-a post should be able to store a static file |
||
| pass | ||
|
|
||
| class Comment(Content): | ||
| post = models.ForeignKey(Post, on_delete=models.CASCADE) | ||
|
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. why linking comment to post? what about comment on a comment. review it |
||
|
|
||
| class Like(models.Model): | ||
| profil = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
| Content = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
|
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. you are using "Content" class name to name a field on an other class |
||
| created_at = models.DateField() | ||
|
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. created_at should be created, handled with a mixin automatically and must be a datetime |
||
|
|
||
| class share(models.Model): | ||
|
Member
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. Model name don't start like this. Refer to the PEP8 documentation for coding style guideline |
||
| sender = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
| recipient = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
| post = models.ForeignKey(Post, on_delete=models.CASCADE) | ||
|
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. two things can be shared: post & comment. handle this |
||
|
|
||
| class Notification(models.Model): | ||
| sender = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
| recipient = models.ForeignKey(Profil, on_delete=models.CASCADE) | ||
| created_at = models.DateField() | ||
| title = models.TextField(max_length=50) | ||
| message = models.TextField(max_length=100) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| # Create your models here. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| from django.shortcuts import render | ||
|
|
||
| # Create your views 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/