Now the sample-data command generate attachments and a main wiki page per project
parent
dfde44a12a
commit
d865ab1615
|
@ -1,15 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import random
|
||||
import datetime
|
||||
|
||||
from sampledatahelper.helper import SampleDataHelper
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import transaction
|
||||
from django.utils.timezone import now
|
||||
|
||||
from django.contrib.webdesign import lorem_ipsum
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from sampledatahelper.helper import SampleDataHelper
|
||||
|
||||
from greenmine.base.users.models import *
|
||||
from greenmine.projects.models import *
|
||||
|
@ -21,6 +19,14 @@ from greenmine.projects.issues.models import *
|
|||
#from greenmine.projects.documents.models import *
|
||||
from greenmine.projects.wiki.models import *
|
||||
|
||||
import random
|
||||
import datetime
|
||||
|
||||
ATTACHMENT_SAMPLE_DATA = [
|
||||
"greenmine/projects/management/commands/sample_data",
|
||||
[".txt", ]
|
||||
]
|
||||
|
||||
COLOR_CHOICES = [
|
||||
"#FC8EAC",
|
||||
"#A5694F",
|
||||
|
@ -40,8 +46,7 @@ COLOR_CHOICES = [
|
|||
"#FFFF00",
|
||||
"#C0FF33",
|
||||
"#B6DA55",
|
||||
"#2099DB",
|
||||
]
|
||||
"#2099DB"]
|
||||
|
||||
|
||||
SUBJECT_CHOICES = [
|
||||
|
@ -60,23 +65,25 @@ SUBJECT_CHOICES = [
|
|||
"Exception is thrown if trying to add a folder with existing name",
|
||||
"Feature/improved image admin",
|
||||
"Support for bulk actions",
|
||||
"Migrate to Python 3 and milk a beautiful cow"
|
||||
]
|
||||
"Migrate to Python 3 and milk a beautiful cow"]
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
sd = SampleDataHelper(seed=12345678901)
|
||||
|
||||
@transaction.commit_on_success
|
||||
@transaction.atomic
|
||||
def handle(self, *args, **options):
|
||||
self.users = [User.objects.get(is_superuser=True)]
|
||||
|
||||
# create users
|
||||
for x in range(10):
|
||||
self.users.append(self.create_user(x))
|
||||
|
||||
# projects
|
||||
# create project
|
||||
for x in range(4):
|
||||
project = self.create_project(x)
|
||||
|
||||
# added memberships
|
||||
for user in self.users:
|
||||
Membership.objects.create(
|
||||
project=project,
|
||||
|
@ -85,7 +92,7 @@ class Command(BaseCommand):
|
|||
|
||||
start_date = now() - datetime.timedelta(55)
|
||||
|
||||
# create random milestones
|
||||
# create milestones
|
||||
for y in range(self.sd.int(1, 5)):
|
||||
end_date = start_date + datetime.timedelta(15)
|
||||
milestone = self.create_milestone(project, start_date, end_date)
|
||||
|
@ -94,12 +101,15 @@ class Command(BaseCommand):
|
|||
for z in range(self.sd.int(3, 7)):
|
||||
us = self.create_us(project, milestone)
|
||||
|
||||
# create tasks
|
||||
rang = (1, 4) if start_date <= now() and end_date <= now() else (0, 6)
|
||||
for w in range(self.sd.int(*rang)):
|
||||
if start_date <= now() and end_date <= now():
|
||||
task = self.create_task(project, milestone, us, start_date, end_date, closed=True)
|
||||
task = self.create_task(project, milestone, us, start_date,
|
||||
end_date, closed=True)
|
||||
elif start_date <= now() and end_date >= now():
|
||||
task = self.create_task(project, milestone, us, start_date, now())
|
||||
task = self.create_task(project, milestone, us, start_date,
|
||||
now())
|
||||
else:
|
||||
# No task on not initiated milestones
|
||||
pass
|
||||
|
@ -118,45 +128,79 @@ class Command(BaseCommand):
|
|||
#for y in range(self.sd.int(15,25)):
|
||||
# question = self.create_question(project)
|
||||
|
||||
# create a wiki page
|
||||
wiki_page = self.create_wiki(project, "home")
|
||||
|
||||
def create_attachment(self, object):
|
||||
attachment = Attachment.objects.create(
|
||||
project=object.project,
|
||||
content_type=ContentType.objects.get_for_model(object.__class__),
|
||||
content_object=object,
|
||||
object_id=object.id,
|
||||
owner=object.project.owner,
|
||||
attached_file=self.sd.image_from_directory(*ATTACHMENT_SAMPLE_DATA))
|
||||
|
||||
return attachment
|
||||
|
||||
def create_wiki(self, project, slug):
|
||||
wiki_page = WikiPage.objects.create(
|
||||
project=project,
|
||||
slug=slug,
|
||||
content=self.sd.paragraphs(3,15),
|
||||
owner=project.owner)
|
||||
|
||||
for i in range(self.sd.int(0, 4)):
|
||||
attachment = self.create_attachment(wiki_page)
|
||||
|
||||
return wiki_page
|
||||
|
||||
#def create_question(self, project):
|
||||
# question = Question.objects.create(
|
||||
# project=project,
|
||||
# subject=self.sd.choice(SUBJECT_CHOICES),
|
||||
# content=self.sd.paragraph(),
|
||||
# owner=project.owner,
|
||||
# status=self.sd.db_object_from_queryset(project.question_status.all()),
|
||||
# tags=self.sd.words(1,5).split(" "),
|
||||
# )
|
||||
|
||||
# project=project,
|
||||
# subject=self.sd.choice(SUBJECT_CHOICES),
|
||||
# content=self.sd.paragraph(),
|
||||
# owner=project.owner,
|
||||
# status=self.sd.db_object_from_queryset(project.question_status.all()),
|
||||
# tags=self.sd.words(1,5).split(" "))
|
||||
#
|
||||
# for i in range(self.sd.int(0, 4)):
|
||||
# attachment = self.create_attachment(question)
|
||||
#
|
||||
# return question
|
||||
|
||||
def create_bug(self, project):
|
||||
bug = Issue.objects.create(
|
||||
project=project,
|
||||
subject=self.sd.choice(SUBJECT_CHOICES),
|
||||
description=self.sd.paragraph(),
|
||||
owner=project.owner,
|
||||
severity=self.sd.db_object_from_queryset(Severity.objects.filter(project=project)),
|
||||
status=self.sd.db_object_from_queryset(IssueStatus.objects.filter(project=project)),
|
||||
priority=self.sd.db_object_from_queryset(Priority.objects.filter(project=project)),
|
||||
type=self.sd.db_object_from_queryset(IssueType.objects.filter(project=project)),
|
||||
tags=self.sd.words(1, 5).split(" "),
|
||||
)
|
||||
project=project,
|
||||
subject=self.sd.choice(SUBJECT_CHOICES),
|
||||
description=self.sd.paragraph(),
|
||||
owner=project.owner,
|
||||
severity=self.sd.db_object_from_queryset(Severity.objects.filter(
|
||||
project=project)),
|
||||
status=self.sd.db_object_from_queryset(IssueStatus.objects.filter(
|
||||
project=project)),
|
||||
priority=self.sd.db_object_from_queryset(Priority.objects.filter(
|
||||
project=project)),
|
||||
type=self.sd.db_object_from_queryset(IssueType.objects.filter(
|
||||
project=project)),
|
||||
tags=self.sd.words(1, 5).split(" "))
|
||||
|
||||
for i in range(self.sd.int(0, 4)):
|
||||
attachment = self.create_attachment(bug)
|
||||
|
||||
return bug
|
||||
|
||||
def create_task(self, project, milestone, us, min_date, max_date, closed=False):
|
||||
task = Task(
|
||||
subject=self.sd.choice(SUBJECT_CHOICES),
|
||||
description=self.sd.paragraph(),
|
||||
project=project,
|
||||
owner=self.sd.choice(self.users),
|
||||
milestone=milestone,
|
||||
user_story=us,
|
||||
finished_date=None,
|
||||
assigned_to = self.sd.db_object_from_queryset(
|
||||
project.memberships.all()).user
|
||||
)
|
||||
subject=self.sd.choice(SUBJECT_CHOICES),
|
||||
description=self.sd.paragraph(),
|
||||
project=project,
|
||||
owner=self.sd.choice(self.users),
|
||||
milestone=milestone,
|
||||
user_story=us,
|
||||
finished_date=None,
|
||||
assigned_to = self.sd.db_object_from_queryset(
|
||||
project.memberships.all()).user)
|
||||
|
||||
if closed:
|
||||
task.status = project.task_statuses.get(order=4)
|
||||
else:
|
||||
|
@ -166,69 +210,75 @@ class Command(BaseCommand):
|
|||
task.finished_date = self.sd.datetime_between(min_date, max_date)
|
||||
|
||||
task.save()
|
||||
|
||||
for i in range(self.sd.int(0, 4)):
|
||||
attachment = self.create_attachment(task)
|
||||
|
||||
return task
|
||||
|
||||
def create_us(self, project, milestone=None):
|
||||
us = UserStory.objects.create(
|
||||
subject=self.sd.choice(SUBJECT_CHOICES),
|
||||
project=project,
|
||||
owner=self.sd.choice(self.users),
|
||||
description=self.sd.paragraph(),
|
||||
milestone=milestone,
|
||||
status=self.sd.db_object_from_queryset(project.us_statuses.filter(is_closed=False)),
|
||||
tags=self.sd.words(1, 3).split(" ")
|
||||
subject=self.sd.choice(SUBJECT_CHOICES),
|
||||
project=project,
|
||||
owner=self.sd.choice(self.users),
|
||||
description=self.sd.paragraph(),
|
||||
milestone=milestone,
|
||||
status=self.sd.db_object_from_queryset(project.us_statuses.filter(
|
||||
is_closed=False)),
|
||||
tags=self.sd.words(1, 3).split(" ")
|
||||
)
|
||||
|
||||
for role_points in us.role_points.all():
|
||||
if milestone:
|
||||
role_points.points = self.sd.db_object_from_queryset(
|
||||
us.project.points.exclude(value=None))
|
||||
us.project.points.exclude(value=None))
|
||||
else:
|
||||
role_points.points = self.sd.db_object_from_queryset(
|
||||
us.project.points.all())
|
||||
us.project.points.all())
|
||||
|
||||
role_points.save()
|
||||
|
||||
for i in range(self.sd.int(0, 4)):
|
||||
attachment = self.create_attachment(us)
|
||||
|
||||
return us
|
||||
|
||||
def create_milestone(self, project, start_date, end_date):
|
||||
milestone = Milestone.objects.create(
|
||||
project=project,
|
||||
name='Sprint {0}-{1}-{2}'.format(start_date.year,
|
||||
start_date.month,
|
||||
start_date.day),
|
||||
owner=project.owner,
|
||||
created_date=start_date,
|
||||
modified_date=start_date,
|
||||
estimated_start=start_date,
|
||||
estimated_finish=end_date,
|
||||
order=10
|
||||
)
|
||||
project=project,
|
||||
name='Sprint {0}-{1}-{2}'.format(start_date.year,
|
||||
start_date.month,
|
||||
start_date.day),
|
||||
owner=project.owner,
|
||||
created_date=start_date,
|
||||
modified_date=start_date,
|
||||
estimated_start=start_date,
|
||||
estimated_finish=end_date,
|
||||
order=10)
|
||||
|
||||
return milestone
|
||||
|
||||
def create_project(self, counter):
|
||||
# create project
|
||||
project = Project.objects.create(
|
||||
name='Project Example {0}'.format(counter),
|
||||
description='Project example {0} description'.format(counter),
|
||||
owner=random.choice(self.users),
|
||||
public=True,
|
||||
total_story_points=self.sd.int(100, 150),
|
||||
total_milestones=self.sd.int(5,10)
|
||||
)
|
||||
name='Project Example {0}'.format(counter),
|
||||
description='Project example {0} description'.format(counter),
|
||||
owner=random.choice(self.users),
|
||||
public=True,
|
||||
total_story_points=self.sd.int(100, 150),
|
||||
total_milestones=self.sd.int(5,10))
|
||||
|
||||
return project
|
||||
|
||||
def create_user(self, counter):
|
||||
user = User.objects.create(
|
||||
username='user-{0}'.format(counter),
|
||||
first_name=self.sd.name('es'),
|
||||
last_name=self.sd.surname('es'),
|
||||
email=self.sd.email(),
|
||||
token=''.join(random.sample('abcdef0123456789', 10)),
|
||||
color=self.sd.choice(COLOR_CHOICES)
|
||||
)
|
||||
username='user-{0}'.format(counter),
|
||||
first_name=self.sd.name('es'),
|
||||
last_name=self.sd.surname('es'),
|
||||
email=self.sd.email(),
|
||||
token=''.join(random.sample('abcdef0123456789', 10)),
|
||||
color=self.sd.choice(COLOR_CHOICES))
|
||||
|
||||
user.set_password('user{0}'.format(counter))
|
||||
user.save()
|
||||
|
||||
return user
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
KALEIDOS MANIFESTO
|
||||
==================
|
||||
|
||||
* In the beginning, it's the people
|
||||
* Code should be beautiful
|
||||
* Customers are not a necessary evil
|
||||
* Love your work and your work will be loved
|
||||
* Shelfware is wrong
|
||||
* Let us surprise you
|
||||
* 1.618033988749894848204586834
|
||||
* In the end, it's the people
|
|
@ -0,0 +1,15 @@
|
|||
WHAT IS THE PI WEEK?
|
||||
====================
|
||||
|
||||
ΠWEEK /paɪ wiːk/ is an original idea by Kaleidos and it consists in allowing employees from participant technology companies to leave their ongoing work in standby and dedicate an entire week to personal projects. The plan is to enjoy a ΠWEEK every six months, particularly in December and July, and allow employees to play and innovate with only two rules in mind:
|
||||
|
||||
* Only free & open source code can be used for development.
|
||||
* By the end of the ΠWEEK, there must be a functional demo of some type.
|
||||
|
||||
ΠWEEK stands for Personal Innovation Week and it is meant to foster innovation and creativity in a near limitless environment of several fellow companies. No commercial purpose is asked, no specific agenda imposed, just a week for everyone to do whatever they wish most.
|
||||
|
||||
The mechanics is fairly simple. During the weeks prior to the ΠWEEK, some people will privately announce their projects so they can attract partners. This process naturally ends the Sunday before ΠWEEK starts so projects and teams are ready for action Monday morning.
|
||||
|
||||
So far, there has been two ΠWEEKs, on December 2011, with just Kaleidos as a participant company and on July 2012, with Kaleidos, Secuoyas and Yaco. This edition, on December 2012, has Wadobo and Secuoyas as excited fellow companies. We will continue to invite more and more companies each edition until this becomes a nationwide event.
|
||||
|
||||
The ultimate goal is to defy the current state of mind that relegates “innovation” to an empty word or, in the best case, to a top-down strategy. For the doubtful out there, try it before you despise it. The first to see the benefits were our clients.
|
|
@ -0,0 +1,28 @@
|
|||
GREENMINE TEAM
|
||||
==============
|
||||
|
||||
|-----------------------------------------------|
|
||||
| NAME | TWITTER | JOB |
|
||||
|-----------------------------------------------|
|
||||
| Andrey Antukhi | @niwibe | Back Dev |
|
||||
|-----------------------------------------------|
|
||||
| Jesús Espino | @jespinog | Back Dev |
|
||||
|-----------------------------------------------|
|
||||
| David Barrgán | @bameda | Back Dev |
|
||||
|-----------------------------------------------|
|
||||
| Alejandro Alonso | @_superalex_ | Back Dev |
|
||||
|-----------------------------------------------|
|
||||
| Andrés Moya | @hirunatan | Back Dev |
|
||||
|-----------------------------------------------|
|
||||
| Alejandro Gómex | @dialelo | Back Dev |
|
||||
|-----------------------------------------------|
|
||||
| Alonso Torres | @Alotor | Back Dev |
|
||||
|-----------------------------------------------|
|
||||
| Xavier Julián | @Xaviju | Front Dev |
|
||||
|-----------------------------------------------|
|
||||
| Pilar Esteban | @devilme | UX/Designer |
|
||||
|-----------------------------------------------|
|
||||
|
||||
Kaleidos OpenSource SL - http://kaleidos.net
|
||||
ΠWEEK (Personal Innovation Week) - http://piweek.es
|
||||
|
Loading…
Reference in New Issue