Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #871 from kawazrepos/fire
Browse files Browse the repository at this point in the history
1年以上更新されていないプロジェクトが炎上するようになった
  • Loading branch information
giginet committed Mar 29, 2015
2 parents 93e51d8 + d1195d6 commit f570428
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/kawaz/apps/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ def get_icon(self, size):
def active_members(self):
return self.members.filter(is_active=True)

@property
def is_legacy(self):
"""
企画中か活動中、かつ365日以上更新されていない場合、Trueが返ります
"""
import datetime
from django.utils import timezone
now = timezone.now()
one_year_ago = now - datetime.timedelta(days=365)
return self.status in ['planning', 'active',] and self.updated_at < one_year_ago

get_small_icon = lambda self: self.get_icon('small')
get_middle_icon = lambda self: self.get_icon('middle')
get_large_icon = lambda self: self.get_icon('large')
Expand Down
28 changes: 27 additions & 1 deletion src/kawaz/apps/projects/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.test import TestCase
from django.contrib.auth.models import AnonymousUser
from django.core.exceptions import PermissionDenied

from .factories import ProjectFactory, CategoryFactory
from kawaz.core.personas.models import Persona
from kawaz.core.personas.tests.factories import PersonaFactory
Expand Down Expand Up @@ -284,3 +283,30 @@ def test_active_members_contains_active_user_only(self):
self.assertIn(project.administrator, project.active_members)
self.assertIn(user0, project.active_members)
self.assertNotIn(user1, project.active_members)

def test_is_legacy(self):
"""
企画中か活動中、かつ365日以上更新されていないプロジェクトでは、is_legacyがTrueを返す
"""
STATUS = (
('planning', True),
('active', True),
('paused', False),
('eternal', False),
('done', False),
)

for status, is_legasy in STATUS:
new_project = ProjectFactory(status=status)
self.assertFalse(new_project.is_legacy, new_project)

import datetime
from django.utils import timezone
past = timezone.now() - datetime.timedelta(days=365)
old_project = ProjectFactory(status=status)
old_project.updated_at = past

if is_legasy:
self.assertTrue(old_project.is_legacy)
else:
self.assertFalse(old_project.is_legacy)
Binary file added src/statics/img/projects/fire.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/statics/less/projects.less
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
.tiled-project-list {
min-width: 200px;

.project-panel {
&.legacy-project {
background-image: url("../img/projects/fire.png");
}
}

.project-list-item {
margin: 0 0 20px;
border: none;
Expand Down
2 changes: 1 addition & 1 deletion src/templates/projects/components/list-item.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<a href="{{ project.get_absolute_url }}">
<div class="panel-body">
<div class="panel-body project-panel{% if project.is_legacy %} legacy-project{% endif %}">
<div class="project-thumbnail">
<img class="group list-group-image" src="{{ project.get_large_icon }}" height="90px" alt="{{ project.title }} Thumbnail" />
</div>
Expand Down

0 comments on commit f570428

Please sign in to comment.