Skip to content
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

new release #507

Merged
merged 1 commit into from
Oct 4, 2023
Merged

new release #507

merged 1 commit into from
Oct 4, 2023

Conversation

ashwin31
Copy link
Member

@ashwin31 ashwin31 commented Oct 4, 2023

No description provided.

Copy link

@code-review-doctor code-review-doctor bot left a comment

Choose a reason for hiding this comment

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

Some things to consider. View full project report here.

from common.utils import COUNTRIES
from teams.models import Teams


class Contact(models.Model):
class Contact(BaseModel):

Choose a reason for hiding this comment

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

This model has lots of fields. Consider splitting into multiple models. More info.

Profile, related_name="contact_created_by", on_delete=models.SET_NULL, null=True
)
created_on = models.DateTimeField(_("Created on"), auto_now_add=True)
twitter_username = models.CharField(max_length=255, blank=True,null=True)

Choose a reason for hiding this comment

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

Suggested change
twitter_username = models.CharField(max_length=255, blank=True,null=True)
twitter_username = models.CharField(max_length=255, blank=True, default="")

null=True on a string field causes inconsistent data types because the value can be either str or None. This adds complexity and maybe bugs, but can be solved by replacing null=True with default="". More details.

if user is None or user.is_anonymous:
self.created_by = None
self.updated_by = None
super(BaseModel, self).save(*args, **kwargs)

Choose a reason for hiding this comment

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

Suggested change
super(BaseModel, self).save(*args, **kwargs)
super().save(*args, **kwargs)

It's unnecessary to use arguments when calling super for the parent class. Explained here.

self.updated_by = None
# If updated only set updated_by value don't touch created_by
self.updated_by = user
super(BaseModel, self).save(*args, **kwargs)

Choose a reason for hiding this comment

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

Suggested change
super(BaseModel, self).save(*args, **kwargs)
super().save(*args, **kwargs)

As above, These super arguments are unnecessary.

def save(self, *args, **kwargs):
self.slug = slugify(self.name)
super().save(*args, **kwargs)


class Account(models.Model):
class Account(BaseModel):

Choose a reason for hiding this comment

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

This model has lots of fields. Consider splitting into multiple models. More.

Comment on lines +220 to +225
return {
'email' : self.user.email,
'id' : self.user.id,
'is_active' : self.user.is_active,
'profile_pic' : self.user.profile_pic
}

Choose a reason for hiding this comment

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

Suggested change
return {
'email' : self.user.email,
'id' : self.user.id,
'is_active' : self.user.is_active,
'profile_pic' : self.user.profile_pic
}
return {
"email": self.user.email,
"id": self.user_id,
"is_active": self.user.is_active,
"profile_pic": self.user.profile_pic,
}

def user_details(self):
return {
'email' : self.user.email,
'id' : self.user.id,

Choose a reason for hiding this comment

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

self.user.id performs a database read when id is evaluated. You could take advantage of Django's caching of related fields by using self.user_id, which does not do a database read. More.

from common.utils import CURRENCY_CODES
from teams.models import Teams


class Invoice(models.Model):
class Invoice(BaseModel):

Choose a reason for hiding this comment

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

This model has lots of fields. Consider splitting into multiple models. Read more.


class Lead(models.Model):
class Lead(BaseModel):

Choose a reason for hiding this comment

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

This model has lots of fields. Consider splitting into multiple models. More info.



class Event(models.Model):
class PlannerEvent(BaseModel):

Choose a reason for hiding this comment

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

This model has lots of fields. Consider splitting into multiple models. Read more.

@ashwin31 ashwin31 merged commit 4dc734a into master Oct 4, 2023
@ashwin31 ashwin31 deleted the new_release branch October 4, 2023 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant