-
Notifications
You must be signed in to change notification settings - Fork 1
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
Sourcery Starbot ⭐ refactored ilyeshammadi/django-publishable #6
base: develop
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -100,11 +100,7 @@ def publish(self): | |
# Create a copy of the wanted to publish instance | ||
published = clone_model(self) | ||
|
||
# Delete the previous published to save space | ||
previous_published_id = None | ||
if self.published: | ||
previous_published_id = self.published.id | ||
|
||
previous_published_id = self.published.id if self.published else None | ||
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. Function
This removes the following comments ( why? ):
|
||
self.published = published | ||
self.save(broadcast_draft=False) | ||
|
||
|
@@ -119,9 +115,8 @@ def delete(self, using=None, keep_parents=False, fake=True): | |
if self.type == TYPES.DRAFT: | ||
if not fake: | ||
return super(Publishable, self).delete(using, keep_parents) | ||
else: | ||
self.is_deleted = True | ||
self.save() | ||
self.is_deleted = True | ||
self.save() | ||
Comment on lines
-122
to
+119
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. Function
|
||
|
||
def save(self, force_insert=False, force_update=False, using=None, update_fields=None, broadcast_draft=True): | ||
super(Publishable, self).save(force_insert, force_update, using, update_fields) | ||
|
@@ -135,8 +130,8 @@ def broadcast_need_to_published(self): | |
specific publisher | ||
:return: Draft | ||
""" | ||
if Draft.objects.filter(object_id=self.id).exists(): | ||
draft = Draft.objects.get(object_id=self.id) | ||
else: | ||
draft = Draft.objects.create(content_object=self) | ||
return draft | ||
return ( | ||
Draft.objects.get(object_id=self.id) | ||
if Draft.objects.filter(object_id=self.id).exists() | ||
else Draft.objects.create(content_object=self) | ||
) | ||
Comment on lines
-138
to
+137
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. Function
|
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.
Function
select_from_queryset
refactored with the following changes:reintroduce-else
)assign-if-exp
)swap-if-expression
)