Commit 9c347d50 authored by Okhin's avatar Okhin
Browse files

Adding boolean flags and methos on the Article

parent 3aed3da5
Pipeline #2604 passed with stages
in 3 minutes and 8 seconds
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2019-05-15 10:50
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rp', '0021_auto_20190507_1438'),
operations = [
field=models.BooleanField(default=False, verbose_name='Article archived'),
field=models.BooleanField(default=False, verbose_name='Article directly quotes us'),
field=models.BooleanField(default=False, verbose_name='Article speaks of us'),
......@@ -91,12 +91,23 @@ class Article(models.Model):
#: priority: True if article have priority
priority = models.BooleanField(default=False)
#: Comma separated list of short tags to describe the article (eg: "Privacy", "Copyright").
#: List of tags used to add subject and topics to an article
tags = TaggableManager(blank=True)
#: Score of the article, modifiedby upvote and downvote methods
score = models.IntegerField(default=0)
#: If the publication is "archived" (not visible by default from the public
#: feeds), this flag is set to True
archive = models.BooleanField(_("Article archived"), default=False)
#: If the article is quoting something LQDN said or wrote
quote = models.BooleanField(_("Article directly quotes us"),
#: If the article speaks about something LQDN did or wrote
speak = models.BooleanField(_("Article speaks of us"), default=False)
class Meta:
verbose_name = _("Article")
verbose_name_plural = _("Articles")
......@@ -115,6 +126,36 @@ class Article(models.Model):
""" Returns article title. """
return self.title
# Flags logic
def toggle_speak(self):
"""Toggle the speak flag"""
self.speak = not self.speak
return self
def toggle_archive(self):
"""Toggle the archive flag"""
self.archive = not self.archive
return self
def toggle_quote(self):
"""Toggle the quote flag"""
self.quote = not self.quote
return self
def set_flags(self, archive=False, speak=False, quote=False):
This method is used to set _all_ the flags in the state their given as
arguments of this method. The default is False which will unset all flags.
self.archive = archive
self.speak = speak
self.quote = quote
return self
# Finite state logic
@transition(field=status, source='DRAFT', target='PUBLISHED',
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment