# Path: goflow/apptools/models.py
# class DefaultAppModel(models.Model):
#     """Default implementation object class  for process instances.
#     
#     When a process instance starts, the instance has to carry an
#     implementation object that contains the application data. The
#     specifications for the implementation class is:
#     
#     (nothing: now managed by generic relation)
#     
#     This model is used in process simulations: you don't have to define
#     application in activities for this; the DefaultAppModel is used
#     to keep workflow history for displaying to users.
#     """
#     history = models.TextField(editable=False, null=True, blank=True)
#     comment = models.TextField(null=True, blank=True)
#     
#     def __unicode__(self):
#         return 'simulation model %s' % str(self.id)
#     class Admin:
#         list_display = ('__unicode__',)
#     class Meta:
#         verbose_name='Simulation object'


from .models import DefaultAppModel
from django.forms import ModelForm
from django import forms
from datetime import datetime
from django.contrib.contenttypes.models import ContentType
    def save(self, user=None, data=None, commit=True):
        ob = super(StartForm, self).save(commit=commit)
        return ob
    
    def pre_check(self, user=None):
        """may be overriden to do some check before.
        
        an exception should be risen if pre-conditions are not fullfilled
        """
        pass


class DefaultAppForm(BaseForm):
    def save(self, workitem=None, submit_value=None, commit=True):
        ob = super(DefaultAppForm, self).save(commit=False)
        if ob.comment:
            if not ob.history:
                ob.history = 'Init'
            ob.history += '\n---------'
            if workitem:
                ob.history += '\nActivity: [%s]' % workitem.activity.title
            ob.history += '\n%s\n%s' % (datetime.now().isoformat(' '), ob.comment)
            ob.comment = None
        if submit_value:
            if ob.history:
                ob.history += '\n button clicked: [%s]' % submit_value
        ob.save()
        return ob

    class Meta:

# Path: goflow/apptools/models.py
# class DefaultAppModel(models.Model):
#     """Default implementation object class  for process instances.
#     
#     When a process instance starts, the instance has to carry an
#     implementation object that contains the application data. The
#     specifications for the implementation class is:
#     
#     (nothing: now managed by generic relation)
#     
#     This model is used in process simulations: you don't have to define
#     application in activities for this; the DefaultAppModel is used
#     to keep workflow history for displaying to users.
#     """
#     history = models.TextField(editable=False, null=True, blank=True)
#     comment = models.TextField(null=True, blank=True)
#     
#     def __unicode__(self):
#         return 'simulation model %s' % str(self.id)
#     class Admin:
#         list_display = ('__unicode__',)
#     class Meta:
#         verbose_name='Simulation object'


# Path: goflow/apptools/forms.py
from .models import DefaultAppModel
from django.forms import ModelForm
from django import forms
from datetime import datetime
from django.contrib.contenttypes.models import ContentType

    def save(self, user=None, data=None, commit=True):
        ob = super(StartForm, self).save(commit=commit)
        return ob
    
    def pre_check(self, user=None):
        """may be overriden to do some check before.
        
        an exception should be risen if pre-conditions are not fullfilled
        """
        pass


class DefaultAppForm(BaseForm):
    def save(self, workitem=None, submit_value=None, commit=True):
        ob = super(DefaultAppForm, self).save(commit=False)
        if ob.comment:
            if not ob.history:
                ob.history = 'Init'
            ob.history += '\n---------'
            if workitem:
                ob.history += '\nActivity: [%s]' % workitem.activity.title
            ob.history += '\n%s\n%s' % (datetime.now().isoformat(' '), ob.comment)
            ob.comment = None
        if submit_value:
            if ob.history:
                ob.history += '\n button clicked: [%s]' % submit_value
        ob.save()
        return ob

    class Meta:

         model = DefaultAppModel