Task #3531: Add is_featured field to project model

remotes/origin/logger
David Barragán Merino 2015-11-18 16:54:29 +01:00
parent 305cb5cd61
commit 806821469b
5 changed files with 39 additions and 5 deletions

View File

@ -66,9 +66,11 @@ class MembershipInline(admin.TabularInline):
class ProjectAdmin(admin.ModelAdmin): class ProjectAdmin(admin.ModelAdmin):
list_display = ["name", "owner", "created_date", "total_milestones", list_display = ["id", "name", "slug", "is_private", "is_featured", "owner", "created_date"]
"total_story_points"] list_display_links = ["id", "name", "slug"]
list_display_links = list_display list_filter = ("is_private", "is_featured")
list_editable = ["is_featured"]
search_fields = ["id", "name", "slug", "owner__username", "owner__email", "owner__full_name"]
inlines = [RoleInline, MembershipInline, MilestoneInline, NotifyPolicyInline, LikeInline] inlines = [RoleInline, MembershipInline, MilestoneInline, NotifyPolicyInline, LikeInline]
def get_object(self, *args, **kwargs): def get_object(self, *args, **kwargs):

View File

@ -278,6 +278,7 @@ class ProjectWatchersViewSet(WatchersViewSetMixin, ModelListViewSet):
permission_classes = (permissions.ProjectWatchersPermission,) permission_classes = (permissions.ProjectWatchersPermission,)
resource_model = models.Project resource_model = models.Project
###################################################### ######################################################
## Custom values for selectors ## Custom values for selectors
###################################################### ######################################################
@ -295,6 +296,7 @@ class PointsViewSet(MoveOnDestroyMixin, ModelCrudViewSet, BulkUpdateOrderMixin):
move_on_destroy_related_field = "points" move_on_destroy_related_field = "points"
move_on_destroy_project_default_field = "default_points" move_on_destroy_project_default_field = "default_points"
class UserStoryStatusViewSet(MoveOnDestroyMixin, ModelCrudViewSet, BulkUpdateOrderMixin): class UserStoryStatusViewSet(MoveOnDestroyMixin, ModelCrudViewSet, BulkUpdateOrderMixin):
model = models.UserStoryStatus model = models.UserStoryStatus
serializer_class = serializers.UserStoryStatusSerializer serializer_class = serializers.UserStoryStatusSerializer

View File

@ -107,6 +107,9 @@ NUM_ATTACHMENTS = getattr(settings, "SAMPLE_DATA_NUM_ATTACHMENTS", (0, 4))
NUM_LIKES = getattr(settings, "SAMPLE_DATA_NUM_LIKES", (0, 10)) NUM_LIKES = getattr(settings, "SAMPLE_DATA_NUM_LIKES", (0, 10))
NUM_VOTES = getattr(settings, "SAMPLE_DATA_NUM_VOTES", (0, 10)) NUM_VOTES = getattr(settings, "SAMPLE_DATA_NUM_VOTES", (0, 10))
NUM_WATCHERS = getattr(settings, "SAMPLE_DATA_NUM_PROJECT_WATCHERS", (0, 8)) NUM_WATCHERS = getattr(settings, "SAMPLE_DATA_NUM_PROJECT_WATCHERS", (0, 8))
FEATURED_PROJECTS_POSITIONS = [0, 1, 2]
LOOKING_FOR_PEOPLE_PROJECTS_POSITIONS = [0, 1, 2]
class Command(BaseCommand): class Command(BaseCommand):
sd = SampleDataHelper(seed=12345678901) sd = SampleDataHelper(seed=12345678901)
@ -230,6 +233,7 @@ class Command(BaseCommand):
self.create_likes(project) self.create_likes(project)
def create_attachment(self, obj, order): def create_attachment(self, obj, order):
attached_file = self.sd.file_from_directory(*ATTACHMENT_SAMPLE_DATA) attached_file = self.sd.file_from_directory(*ATTACHMENT_SAMPLE_DATA)
membership = self.sd.db_object_from_queryset(obj.project.memberships membership = self.sd.db_object_from_queryset(obj.project.memberships
@ -458,7 +462,9 @@ class Command(BaseCommand):
public_permissions=public_permissions, public_permissions=public_permissions,
total_story_points=self.sd.int(600, 3000), total_story_points=self.sd.int(600, 3000),
total_milestones=self.sd.int(5,10), total_milestones=self.sd.int(5,10),
tags=self.sd.words(1, 10).split(" ")) tags=self.sd.words(1, 10).split(" "),
is_looking_for_people=counter in LOOKING_FOR_PEOPLE_PROJECTS_POSITIONS,
is_featured=cointer in FEATURED_PROJECTS_POSITIONS)
project.is_kanban_activated = True project.is_kanban_activated = True
project.save() project.save()

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('projects', '0027_auto_20150916_1302'),
]
operations = [
migrations.AddField(
model_name='project',
name='is_featured',
field=models.BooleanField(verbose_name='is featured', default=False),
),
]

View File

@ -169,6 +169,7 @@ class Project(ProjectDefaults, TaggedMixin, models.Model):
related_name="projects", null=True, related_name="projects", null=True,
blank=True, default=None, blank=True, default=None,
verbose_name=_("creation template")) verbose_name=_("creation template"))
anon_permissions = TextArrayField(blank=True, null=True, anon_permissions = TextArrayField(blank=True, null=True,
default=[], default=[],
verbose_name=_("anonymous permissions"), verbose_name=_("anonymous permissions"),
@ -180,6 +181,9 @@ class Project(ProjectDefaults, TaggedMixin, models.Model):
is_private = models.BooleanField(default=True, null=False, blank=True, is_private = models.BooleanField(default=True, null=False, blank=True,
verbose_name=_("is private")) verbose_name=_("is private"))
is_featured = models.BooleanField(default=False, null=False, blank=True,
verbose_name=_("is featured"))
userstories_csv_uuid = models.CharField(max_length=32, editable=False, userstories_csv_uuid = models.CharField(max_length=32, editable=False,
null=True, blank=True, null=True, blank=True,
default=None, db_index=True) default=None, db_index=True)
@ -189,7 +193,8 @@ class Project(ProjectDefaults, TaggedMixin, models.Model):
null=True, blank=True, default=None, null=True, blank=True, default=None,
db_index=True) db_index=True)
tags_colors = TextArrayField(dimension=2, null=False, blank=True, verbose_name=_("tags colors"), default=[]) tags_colors = TextArrayField(dimension=2, default=[], null=False, blank=True,
verbose_name=_("tags colors"))
_importing = None _importing = None
class Meta: class Meta: