Now the sample-data command generate attachments and a main wiki page per project

remotes/origin/enhancement/email-actions
David Barragán Merino 2013-10-22 13:58:03 +02:00
parent dfde44a12a
commit d865ab1615
4 changed files with 181 additions and 77 deletions

View File

@ -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,6 +128,32 @@ 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,
@ -125,9 +161,11 @@ class Command(BaseCommand):
# 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(" "),
# )
# 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):
@ -136,12 +174,18 @@ class Command(BaseCommand):
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(" "),
)
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
@ -155,8 +199,8 @@ class Command(BaseCommand):
user_story=us,
finished_date=None,
assigned_to = self.sd.db_object_from_queryset(
project.memberships.all()).user
)
project.memberships.all()).user)
if closed:
task.status = project.task_statuses.get(order=4)
else:
@ -166,6 +210,10 @@ 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):
@ -175,7 +223,8 @@ class Command(BaseCommand):
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)),
status=self.sd.db_object_from_queryset(project.us_statuses.filter(
is_closed=False)),
tags=self.sd.words(1, 3).split(" ")
)
@ -189,6 +238,9 @@ class Command(BaseCommand):
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):
@ -202,20 +254,18 @@ class Command(BaseCommand):
modified_date=start_date,
estimated_start=start_date,
estimated_finish=end_date,
order=10
)
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)
)
total_milestones=self.sd.int(5,10))
return project
@ -226,9 +276,9 @@ class Command(BaseCommand):
last_name=self.sd.surname('es'),
email=self.sd.email(),
token=''.join(random.sample('abcdef0123456789', 10)),
color=self.sd.choice(COLOR_CHOICES)
)
color=self.sd.choice(COLOR_CHOICES))
user.set_password('user{0}'.format(counter))
user.save()
return user

View File

@ -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

View File

@ -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.

View File

@ -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