# Path: journeyman/projects/models.py
# class Project(models.Model):
#     name = models.CharField(max_length=255)
#     active = models.BooleanField(default=True)
# 
#     repository = models.CharField(max_length=255)
#     ssh_key = models.TextField(blank=True)
# 
#     config_file = models.CharField(max_length=255,
#         default='journey.conf/config', blank=True)
#     config_data = models.TextField(blank=True)
# 
#     def get_state(self):
#         try:
#             return self.build_set.all().order_by('-pk')[0].state
#         except IndexError:
#             return 'unknown'
# 
#     def __unicode__(self):
#         return self.name
# 
#     @property
#     def last_build(self):
#         try:
#             return self.build_set.all().order_by('-started')[0]
#         except (self.build_set.model.DoesNotExist, IndexError):
#             return None
# 
#     @property
#     def last_stable_build(self):
#         try:
#             return self.build_set.filter(state='stable').order_by('-started')[0]
#         except (self.build_set.model.DoesNotExist, IndexError):
#             return None
# 
#     @property
#     def outstanding_builds(self):
#         return self.build_set.filter(Q(Q(state='queued') | Q(state='unknown')))
# 
#     @property
#     def builds(self):
#         return self.build_set.exclude(Q(Q(state='queued') | Q(state='unknown')))
# 
# Path: journeyman/projects/forms.py
# class RepositoryForm(forms.Form):
#     name = forms.CharField(
#         help_text='What\'s the name of your awesome project?')
#     repository = forms.CharField(
#         help_text='Please enter a valid repository url \
#         (e.g. git+git://github.com/stephrdev/loetwerk.git)')
# 
# class BuildProcessForm(forms.Form):
#     build_steps = forms.CharField(initial='python setup.py install',
#         widget=forms.Textarea(attrs={'rows':3, 'cols':40}),
#         help_text='Let\'s start off with the easy stuff, please type in all \
#         the commands needed to install your package')
#     test_steps = forms.CharField(initial='python setup.py test',
#         widget=forms.Textarea(attrs={'rows':3, 'cols':40}),
#         help_text='Now tell us how to run your tests. If you should have \
#         many different test suites, just add another line.')
#     dependencies = forms.CharField(required=False, initial='dependencies.txt',
#         widget=forms.Textarea(attrs={'rows':3, 'cols':40}),
#         help_text='Please enter a list of pip requirement files that you \
#         have used to specify your dependencies')
#     test_xmls = forms.CharField(required=False,
#         widget=forms.Textarea(attrs={'rows':3, 'cols':40}),
#         help_text='Please enter a newline separated list of paths of \
#         unit test result xmls.')
# 
# class JourneyConfigOutputForm(forms.Form):
#     pass
# 
# class JourneyConfigFileForm(forms.Form):
#     config_file = forms.CharField(initial="journey.conf/config",
#         help_text="If you leave this field blank, we will store the config \
#         locally.", required=False)
# 
# class ProjectForm(forms.ModelForm):
#     class Meta:
#         model = Project
#         exclude = ['active',]
# 
# Path: journeyman/workers/models.py
# class BuildNode(models.Model):
#     name = models.CharField(max_length=255)
#     active = models.BooleanField(default=True)
# 
#     host = models.CharField(max_length=255)
#     username = models.CharField(max_length=255)
#     ssh_key = models.TextField()
# 
#     def __unicode__(self):
#         return '%s (%s)' % (self.name, self.host)


from django.conf import settings
from django.template import RequestContext
from django.template.loader import render_to_string
from django.shortcuts import render_to_response, get_object_or_404, redirect
from django.http import HttpResponse
from formwizard.forms import SessionFormWizard
from journeyman.projects.models import Project
from journeyman.projects.forms import RepositoryForm, BuildProcessForm, \
    JourneyConfigOutputForm, JourneyConfigFileForm, ProjectForm
from journeyman.workers.models import BuildNode
from django.views.decorators.csrf import csrf_exempt
from django.utils.safestring import mark_safe
                'install': ymlize_list(form.cleaned_data['build_steps']),
                'test': ymlize_list(form.cleaned_data['test_steps']),
                'test_xmls': ymlize_list(form.cleaned_data['test_xmls']),
                'dependencies': ymlize_list(form.cleaned_data['dependencies']),
            })

            # Write the config to extra context.
            self.update_extra_context({'config_file': conf})

        # Proceed.
        return self.get_form_step_data(form)

    def done(self, request, form_list):
        # Create a project using every form field with is available in the
        # model.
        project = Project.objects.create(**dict(
            (k,v) for k,v in self.get_all_cleaned_data().items() 
            if k in Project._meta.get_all_field_names()
        ))

        # And add the config data + save.
        project.config_data = self.get_extra_context().get('config_file', '')
        project.save()

        # Return a nice info page.
        return render_to_response('projects/create_done.html', {
            'project': project
        }, context_instance=RequestContext(request))

# Create a instance of the project wizard.

# Path: journeyman/projects/models.py
# class Project(models.Model):
#     name = models.CharField(max_length=255)
#     active = models.BooleanField(default=True)
# 
#     repository = models.CharField(max_length=255)
#     ssh_key = models.TextField(blank=True)
# 
#     config_file = models.CharField(max_length=255,
#         default='journey.conf/config', blank=True)
#     config_data = models.TextField(blank=True)
# 
#     def get_state(self):
#         try:
#             return self.build_set.all().order_by('-pk')[0].state
#         except IndexError:
#             return 'unknown'
# 
#     def __unicode__(self):
#         return self.name
# 
#     @property
#     def last_build(self):
#         try:
#             return self.build_set.all().order_by('-started')[0]
#         except (self.build_set.model.DoesNotExist, IndexError):
#             return None
# 
#     @property
#     def last_stable_build(self):
#         try:
#             return self.build_set.filter(state='stable').order_by('-started')[0]
#         except (self.build_set.model.DoesNotExist, IndexError):
#             return None
# 
#     @property
#     def outstanding_builds(self):
#         return self.build_set.filter(Q(Q(state='queued') | Q(state='unknown')))
# 
#     @property
#     def builds(self):
#         return self.build_set.exclude(Q(Q(state='queued') | Q(state='unknown')))
# 
# Path: journeyman/projects/forms.py
# class RepositoryForm(forms.Form):
#     name = forms.CharField(
#         help_text='What\'s the name of your awesome project?')
#     repository = forms.CharField(
#         help_text='Please enter a valid repository url \
#         (e.g. git+git://github.com/stephrdev/loetwerk.git)')
# 
# class BuildProcessForm(forms.Form):
#     build_steps = forms.CharField(initial='python setup.py install',
#         widget=forms.Textarea(attrs={'rows':3, 'cols':40}),
#         help_text='Let\'s start off with the easy stuff, please type in all \
#         the commands needed to install your package')
#     test_steps = forms.CharField(initial='python setup.py test',
#         widget=forms.Textarea(attrs={'rows':3, 'cols':40}),
#         help_text='Now tell us how to run your tests. If you should have \
#         many different test suites, just add another line.')
#     dependencies = forms.CharField(required=False, initial='dependencies.txt',
#         widget=forms.Textarea(attrs={'rows':3, 'cols':40}),
#         help_text='Please enter a list of pip requirement files that you \
#         have used to specify your dependencies')
#     test_xmls = forms.CharField(required=False,
#         widget=forms.Textarea(attrs={'rows':3, 'cols':40}),
#         help_text='Please enter a newline separated list of paths of \
#         unit test result xmls.')
# 
# class JourneyConfigOutputForm(forms.Form):
#     pass
# 
# class JourneyConfigFileForm(forms.Form):
#     config_file = forms.CharField(initial="journey.conf/config",
#         help_text="If you leave this field blank, we will store the config \
#         locally.", required=False)
# 
# class ProjectForm(forms.ModelForm):
#     class Meta:
#         model = Project
#         exclude = ['active',]
# 
# Path: journeyman/workers/models.py
# class BuildNode(models.Model):
#     name = models.CharField(max_length=255)
#     active = models.BooleanField(default=True)
# 
#     host = models.CharField(max_length=255)
#     username = models.CharField(max_length=255)
#     ssh_key = models.TextField()
# 
#     def __unicode__(self):
#         return '%s (%s)' % (self.name, self.host)


# Path: journeyman/projects/views.py
from django.conf import settings
from django.template import RequestContext
from django.template.loader import render_to_string
from django.shortcuts import render_to_response, get_object_or_404, redirect
from django.http import HttpResponse
from formwizard.forms import SessionFormWizard
from journeyman.projects.models import Project
from journeyman.projects.forms import RepositoryForm, BuildProcessForm, \
    JourneyConfigOutputForm, JourneyConfigFileForm, ProjectForm
from journeyman.workers.models import BuildNode
from django.views.decorators.csrf import csrf_exempt
from django.utils.safestring import mark_safe

                'install': ymlize_list(form.cleaned_data['build_steps']),
                'test': ymlize_list(form.cleaned_data['test_steps']),
                'test_xmls': ymlize_list(form.cleaned_data['test_xmls']),
                'dependencies': ymlize_list(form.cleaned_data['dependencies']),
            })

            # Write the config to extra context.
            self.update_extra_context({'config_file': conf})

        # Proceed.
        return self.get_form_step_data(form)

    def done(self, request, form_list):
        # Create a project using every form field with is available in the
        # model.
        project = Project.objects.create(**dict(
            (k,v) for k,v in self.get_all_cleaned_data().items() 
            if k in Project._meta.get_all_field_names()
        ))

        # And add the config data + save.
        project.config_data = self.get_extra_context().get('config_file', '')
        project.save()

        # Return a nice info page.
        return render_to_response('projects/create_done.html', {
            'project': project
        }, context_instance=RequestContext(request))

# Create a instance of the project wizard.

create = CreateProjectWizard([RepositoryForm, BuildProcessForm, \