Beispiel #1
0
class DetailReport(GridReport):
  '''
  A list report to show delivery plans for demand.
  '''
  template = 'output/demandplan.html'
  title = _("Demand plan detail")
  model = Demand
  basequeryset = Demand.objects.all()
  permissions = (("view_demand_report", "Can view demand report"),)
  frozenColumns = 0
  editable = False
  multiselect = False
  rows = (
    GridFieldInteger('id', title=_('id'), key=True,editable=False, hidden=True),
    GridFieldText('demand', title=_('demand'), editable=False, formatter='detail', extra="role:'input/demand'"),
    GridFieldText('item', title=_('item'), editable=False, formatter='detail', extra="role:'input/item'"),
    GridFieldText('customer', title=_('customer'), editable=False, formatter='detail', extra="role:'input/customer'"),
    GridFieldNumber('quantity', title=_('quantity'), editable=False),
    GridFieldNumber('planquantity', title=_('planned quantity'), editable=False),
    GridFieldDateTime('due', title=_('due date'), editable=False),
    GridFieldDateTime('plandate', title=_('planned date'), editable=False),
    GridFieldInteger('operationplan', title=_('operationplan'), editable=False),
    )

  @classmethod
  def extra_context(reportclass, request, *args, **kwargs):
    if args and args[0]:
      request.session['lasttab'] = 'plandetail'
    return {'active_tab': 'plandetail'}
Beispiel #2
0
class OperationPlanList(GridReport):
    '''
  A list report to show operationplans.
  '''
    template = 'input/operationplanlist.html'
    title = _("Operationplan List")
    basequeryset = OperationPlan.objects.all()
    model = OperationPlan
    frozenColumns = 1

    rows = (
        GridFieldInteger('id', title=_('identifier'), key=True),
        GridFieldText('operation',
                      title=_('operation'),
                      field_name='operation__name',
                      formatter='operation'),
        GridFieldDateTime('startdate', title=_('start date')),
        GridFieldDateTime('enddate', title=_('end date')),
        GridFieldNumber('quantity', title=_('quantity')),
        GridFieldChoice('status',
                        title=_('status'),
                        choices=OperationPlan.orderstatus),
        GridFieldInteger('owner',
                         title=_('owner'),
                         extra="formatoptions:{defaultValue:''}"),
        GridFieldText('source', title=_('source')),
        GridFieldLastModified('lastmodified'),
    )
Beispiel #3
0
class CalendarBucketList(GridReport):
    '''
  A list report to show calendar buckets.
  '''
    template = 'input/calendarbucketlist.html'
    title = _("Calendar Bucket List")
    basequeryset = CalendarBucket.objects.all()
    model = CalendarBucket
    frozenColumns = 3
    rows = (
        GridFieldInteger('id',
                         title=_('identifier'),
                         formatter='calendarbucket'),
        GridFieldText('calendar',
                      title=_('calendar'),
                      field_name='calendar__name',
                      formatter='calendar'),
        GridFieldDateTime('startdate', title=_('start date')),
        GridFieldDateTime('enddate', title=_('end date'), editable=False),
        GridFieldNumber('value', title=_('value')),
        GridFieldInteger('priority', title=_('priority')),
        GridFieldBool('monday', title=_('Monday')),
        GridFieldBool('tuesday', title=_('Tuesday')),
        GridFieldBool('wednesday', title=_('Wednesday')),
        GridFieldBool('thursday', title=_('Thursday')),
        GridFieldBool('friday', title=_('Friday')),
        GridFieldBool('saturday', title=_('Saturday')),
        GridFieldBool('sunday', title=_('Sunday')),
        GridFieldTime('starttime', title=_('start time')),
        GridFieldTime('endtime', title=_('end time')),
        GridFieldText(
            'source', title=_('source')
        ),  # Not really right, since the engine doesn't read or store it
        GridFieldLastModified('lastmodified'),
    )
Beispiel #4
0
class SubOperationList(GridReport):
    '''
  A list report to show suboperations.
  '''
    template = 'input/suboperationlist.html'
    title = _("Suboperation List")
    basequeryset = SubOperation.objects.all()
    model = SubOperation
    frozenColumns = 1

    rows = (
        GridFieldInteger('id', title=_('identifier'), key=True),
        GridFieldText('operation',
                      title=_('operation'),
                      field_name='operation__name',
                      formatter='operation'),
        GridFieldText('suboperation',
                      title=_('suboperation'),
                      field_name='suboperation__name',
                      formatter='operation'),
        GridFieldInteger('priority', title=_('priority')),
        GridFieldDateTime('effective_start', title=_('effective start')),
        GridFieldDateTime('effective_end', title=_('effective end')),
        GridFieldText('source', title=_('source')),
        GridFieldLastModified('lastmodified'),
    )
Beispiel #5
0
class DetailReport(GridReport):
  '''
  A list report to show operationplans.
  '''
  template = 'output/operationplan.html'
  title = _("Operation detail report")
  model = OperationPlan
  permissions = (("view_operation_report", "Can view operation report"),)
  frozenColumns = 0
  editable = False
  multiselect = False

  @ classmethod
  def basequeryset(reportclass, request, args, kwargs):
    if args and args[0]:
      return OperationPlan.objects.filter(operation__exact=args[0]).extra(select={'operation_in': "select name from operation where out_operationplan.operation = operation.name",})
    else:
      return OperationPlan.objects.extra(select={'operation_in': "select name from operation where out_operationplan.operation = operation.name",})

  @classmethod
  def extra_context(reportclass, request, *args, **kwargs):
    return {'active_tab': 'plandetail'}

  rows = (
    GridFieldInteger('id', title=_('operationplan'), key=True, editable=False),
    GridFieldText('operation', title=_('operation'), formatter='operation', editable=False),
    GridFieldNumber('quantity', title=_('quantity'), editable=False),
    GridFieldDateTime('startdate', title=_('start date'), editable=False),
    GridFieldDateTime('enddate', title=_('end date'), editable=False),
    GridFieldBool('locked', title=_('locked'), editable=False),
    GridFieldNumber('unavailable', title=_('unavailable'), editable=False),
    GridFieldInteger('owner', title=_('owner'), editable=False),
    )
Beispiel #6
0
class DetailReport(GridReport):
    '''
  A list report to show operationplans.
  '''
    template = 'output/operationplan.html'
    title = _("Operation detail report")
    model = OperationPlan
    permissions = (("view_operation_report", "Can view operation report"), )
    frozenColumns = 0
    editable = False
    multiselect = False

    @classmethod
    def basequeryset(reportclass, request, args, kwargs):
        if args and args[0]:
            base = OperationPlan.objects.filter(operation__exact=args[0])
        else:
            base = OperationPlan.objects
        return base.select_related() \
          .extra(select={
            'operation_in': "select name from operation where out_operationplan.operation = operation.name",
            'demand': ("select %s(q || ' : ' || d, ', ') from ("
                       "select round(sum(quantity)) as q, demand as d "
                       "from out_demandpegging "
                       "where out_demandpegging.operationplan = out_operationplan.id "
                       "group by demand order by 1 desc, 2) peg"
                       % string_agg())
            })

    @classmethod
    def extra_context(reportclass, request, *args, **kwargs):
        if args and args[0]:
            request.session['lasttab'] = 'plandetail'
        return {'active_tab': 'plandetail'}

    rows = (
        GridFieldInteger('id',
                         title=_('operationplan'),
                         key=True,
                         editable=False),
        GridFieldText('operation',
                      title=_('operation'),
                      editable=False,
                      formatter='detail',
                      extra="role:'input/operation'"),
        GridFieldNumber('quantity', title=_('quantity'), editable=False),
        GridFieldText('demand',
                      title=_('demand quantity'),
                      formatter='demanddetail',
                      extra="role:'input/demand'",
                      width=300,
                      editable=False),
        GridFieldDateTime('startdate', title=_('start date'), editable=False),
        GridFieldDateTime('enddate', title=_('end date'), editable=False),
        GridFieldNumber('criticality', title=_('criticality'), editable=False),
        GridFieldBool('locked', title=_('locked'), editable=False),
        GridFieldNumber('unavailable', title=_('unavailable'), editable=False),
        GridFieldInteger('owner', title=_('owner'), editable=False),
    )
Beispiel #7
0
class ResourceSkillList(GridReport):
    title = _("resource skills")
    basequeryset = ResourceSkill.objects.all()
    model = ResourceSkill
    frozenColumns = 1
    help_url = "model-reference/resource-skills.html"
    message_when_empty = Template("""
        <h3>Define resource skills</h3>
        <br>
        The table defines all skills a resource has.<br>
        <br><br>
        <div role="group" class="btn-group.btn-group-justified">
        <a href="{{request.prefix}}/data/input/resourceskill/add/" class="btn btn-primary">Create a resource skill</a>
        </div>
        <br>
        """)

    rows = (
        GridFieldInteger(
            "id",
            title=_("identifier"),
            key=True,
            formatter="detail",
            extra='"role":"input/resourceskill"',
        ),
        GridFieldHierarchicalText(
            "resource",
            title=_("resource"),
            field_name="resource__name",
            formatter="detail",
            extra='"role":"input/resource"',
            model=Resource,
        ),
        GridFieldText(
            "skill",
            title=_("skill"),
            field_name="skill__name",
            formatter="detail",
            extra='"role":"input/skill"',
        ),
        GridFieldDateTime("effective_start",
                          title=_("effective start"),
                          initially_hidden=True),
        GridFieldDateTime("effective_end",
                          title=_("effective end"),
                          initially_hidden=True),
        GridFieldInteger("priority",
                         title=_("priority"),
                         initially_hidden=True),
        GridFieldText("source", title=_("source"), initially_hidden=True),
        GridFieldLastModified("lastmodified"),
    )
Beispiel #8
0
class SetupRuleList(GridReport):
    title = _("setup rules")
    basequeryset = SetupRule.objects.all()
    model = SetupRule
    frozenColumns = 1
    help_url = "model-reference/setup-matrices.html"
    message_when_empty = Template("""
        <h3>Define setup matrix rules</h3>
        <br>
        A setup matrix rule defines the changeover cost and duration.<br>
        <br><br>
        <div role="group" class="btn-group.btn-group-justified">
        <a href="{{request.prefix}}/data/input/setuprule/add/" class="btn btn-primary">Add a setup matrix rule</a>
        </div>
        <br>
        """)

    rows = (
        GridFieldInteger(
            "id",
            title=_("identifier"),
            key=True,
            formatter="detail",
            extra='"role":"input/setuprule"',
            initially_hidden=True,
        ),
        GridFieldText(
            "setupmatrix",
            title=_("setup matrix"),
            field_name="setupmatrix__name",
            formatter="detail",
            extra='"role":"input/setupmatrix"',
        ),
        GridFieldInteger("priority", title=_("priority")),
        GridFieldText("fromsetup", title=_("from setup")),
        GridFieldText("tosetup", title=_("to setup")),
        GridFieldDuration("duration", title=_("duration")),
        GridFieldCurrency("cost", title=_("cost"), initially_hidden=True),
        GridFieldText(
            "resource",
            title=_("resource"),
            field_name="resource__name",
            formatter="detail",
            extra='"role":"input/resource"',
            initially_hidden=True,
        ),
        GridFieldLastModified("lastmodified"),
    )
Beispiel #9
0
 def rows(self, request, *args, **kwargs):
     cols = []
     if args:
         for c in (
             SQLColumn.objects.using(request.database)
             .filter(report=args[0])
             .order_by("sequence")
         ):
             if c.format == "number":
                 cols.append(GridFieldNumber(_(c.name), editable=False))
             elif c.format == "datetime":
                 cols.append(GridFieldDateTime(_(c.name), editable=False))
             elif c.format == "date":
                 cols.append(GridFieldDate(_(c.name), editable=False))
             elif c.format == "integer":
                 cols.append(GridFieldInteger(_(c.name), editable=False))
             elif c.format == "duration":
                 cols.append(GridFieldDuration(_(c.name), editable=False))
             elif c.format == "text":
                 cols.append(GridFieldText(_(c.name), editable=False))
             elif c.format == "character":
                 cols.append(GridFieldText(_(c.name), editable=False))
             elif c.format == "bool":
                 cols.append(GridFieldBool(_(c.name), editable=False))
             elif c.format == "currency":
                 cols.append(GridFieldCurrency(_(c.name), editable=False))
     return cols
Beispiel #10
0
class FlowList(GridReport):
    '''
  A list report to show flows.
  '''
    template = 'input/flowlist.html'
    title = _("Flow List")
    basequeryset = Flow.objects.all()
    model = Flow
    frozenColumns = 1

    rows = (
        GridFieldInteger('id',
                         title=_('identifier'),
                         key=True,
                         formatter='flow'),
        GridFieldText('operation',
                      title=_('operation'),
                      field_name='operation__name',
                      formatter='operation'),
        GridFieldText('thebuffer',
                      title=_('buffer'),
                      field_name='thebuffer__name',
                      formatter='buffer'),
        GridFieldChoice('type', title=_('type'), choices=Flow.types),
        GridFieldNumber('quantity', title=_('quantity')),
        GridFieldDateTime('effective_start', title=_('effective start')),
        GridFieldDateTime('effective_end', title=_('effective end')),
        GridFieldText('name', title=_('name')),
        GridFieldText('alternate', title=_('alternate')),
        GridFieldNumber('priority', title=_('priority')),
        GridFieldChoice('search', title=_('search mode'), choices=searchmode),
        GridFieldText('source', title=_('source')),
        GridFieldLastModified('lastmodified'),
    )
Beispiel #11
0
class LoadList(GridReport):
    '''
  A list report to show loads.
  '''
    template = 'input/loadlist.html'
    title = _("Load List")
    basequeryset = Load.objects.all()
    model = Load
    frozenColumns = 1

    rows = (
        GridFieldInteger('id',
                         title=_('identifier'),
                         key=True,
                         formatter='load'),
        GridFieldText('operation',
                      title=_('operation'),
                      field_name='operation__name',
                      formatter='operation'),
        GridFieldText('resource',
                      title=_('resource'),
                      field_name='resource__name',
                      formatter='resource'),
        GridFieldText('skill', title=_('skill'), formatter='skill'),
        GridFieldNumber('quantity', title=_('quantity')),
        GridFieldDateTime('effective_start', title=_('effective start')),
        GridFieldDateTime('effective_end', title=_('effective end')),
        GridFieldText('name', title=_('name')),
        GridFieldText('alternate', title=_('alternate')),
        GridFieldNumber('priority', title=_('priority')),
        GridFieldText('setup', title=_('setup')),
        GridFieldChoice('search', title=_('search mode'), choices=searchmode),
        GridFieldText('source', title=_('source')),
        GridFieldLastModified('lastmodified'),
    )
Beispiel #12
0
class ItemDistributionList(GridReport):
    '''
  A list report to show item distribution.
  '''
    template = 'input/itemdistributionlist.html'
    title = _("Item Distribution List")
    basequeryset = ItemDistribution.objects.all()
    model = ItemDistribution
    frozenColumns = 1

    rows = (
        GridFieldInteger('id',
                         title=_('identifier'),
                         key=True,
                         formatter='itemdistribution'),
        GridFieldText('item', title=_('item'), formatter='item'),
        GridFieldText('location', title=_('location'), formatter='location'),
        GridFieldText('origin', title=_('origin'), formatter='location'),
        GridFieldDuration('leadtime', title=_('lead time')),
        GridFieldNumber('sizeminimum', title=_('size minimum')),
        GridFieldNumber('sizemultiple', title=_('size multiple')),
        GridFieldCurrency('cost', title=_('cost')),
        GridFieldNumber('priority', title=_('priority')),
        GridFieldDateTime('effective_start', title=_('effective start')),
        GridFieldDateTime('effective_end', title=_('effective end')),
        GridFieldText('source', title=_('source')),
        GridFieldLastModified('lastmodified'),
    )
Beispiel #13
0
class PurchaseOrderList(GridReport):
    '''
  A list report to show purchase orders.
  '''
    template = 'input/purchaseorderlist.html'
    title = _("Purchase order List")
    basequeryset = PurchaseOrder.objects.all()
    model = PurchaseOrder
    frozenColumns = 1

    rows = (
        GridFieldInteger('id', title=_('identifier'), key=True),
        GridFieldText('reference', title=_('reference')),
        GridFieldChoice('status',
                        title=_('status'),
                        choices=PurchaseOrder.orderstatus),
        GridFieldText('item',
                      title=_('item'),
                      field_name='item__name',
                      formatter='item'),
        GridFieldText('supplier',
                      title=_('supplier'),
                      field_name='supplier__name',
                      formatter='supplier'),
        GridFieldDateTime('startdate', title=_('start date')),
        GridFieldDateTime('enddate', title=_('end date')),
        GridFieldNumber('quantity', title=_('quantity')),
        GridFieldNumber('criticality', title=_('criticality'), editable=False),
        GridFieldText('source', title=_('source')),
        GridFieldLastModified('lastmodified'),
    )
Beispiel #14
0
class BaseReport(GridReport):
  '''
  A list report to show constraints.
  '''
  template = 'output/constraint.html'
  title = _("Constraint report")
  basequeryset = Constraint.objects.all()
  model = Constraint
  permissions = (("view_constraint_report", "Can view constraint report"),)
  frozenColumns = 0
  editable = False
  multiselect = False
  help_url = 'user-guide/user-interface/plan-analysis/constraint-report.html'
  rows = (
    GridFieldInteger('id', title=_('id'),  key=True,editable=False, hidden=True),
    GridFieldText('demand', title=_('demand'), editable=False, formatter='detail', extra="role:'input/demand'"),
    GridFieldText('entity', title=_('entity'), editable=False, width=80, align='center'),
    #. Translators: Translation included with Django
    GridFieldText('name', title=_('name'), editable=False, width=100, align='center'),
    GridFieldText('owner', title=_('owner'), editable=False, extra='formatter:probfmt'),
    GridFieldText('description', title=_('description'), editable=False, width=350),
    GridFieldDateTime('startdate', title=_('start date'), editable=False),
    GridFieldDateTime('enddate', title=_('end date'), editable=False),
    GridFieldNumber('weight', title=_('weight'), editable=False),
    )

  @classmethod
  def extra_context(reportclass, request, *args, **kwargs):
    if args and args[0]:
      request.session['lasttab'] = 'constraint'
    return {'active_tab': 'constraint'}
Beispiel #15
0
class TaskReport(GridReport):
  '''
  A list report to review the history of actions.
  '''
  template = 'execute/execute.html'
  title = _('Task status')
  basequeryset = Task.objects.all()
  model = Task
  frozenColumns = 0
  multiselect = False
  editable = False
  height = 150
  default_sort = (0, 'desc')

  rows = (
    GridFieldInteger('id', title=_('identifier'), key=True),
    GridFieldText('name', title=_('name'), editable=False, align='center'),
    GridFieldDateTime('submitted', title=_('submitted'), editable=False, align='center'),
    GridFieldDateTime('started', title=_('started'), editable=False, align='center'),
    GridFieldDateTime('finished', title=_('finished'), editable=False, align='center'),
    GridFieldText('status', title=_('status'), editable=False, align='center', extra="formatter:status"),
    GridFieldText('message', title=_('message'), editable=False, width=500),
    GridFieldText('arguments', title=_('arguments'), editable=False),
    GridFieldText('user', title=_('user'), field_name='user__username', editable=False, align='center'),
    )

  @classmethod
  def extra_context(reportclass, request, *args, **kwargs):
    try: constraint = int(request.session['constraint'])
    except: constraint = 15

    # Synchronize the scenario table with the settings
    Scenario.syncWithSettings()

    # Loop over all fixtures of all apps and directories
    fixtures = set()
    folders = list(settings.FIXTURE_DIRS)
    for app in get_apps():
      if app.__name__.startswith('django'): continue
      folders.append(os.path.join(os.path.dirname(app.__file__), 'fixtures'))
    for f in folders:
      try:
        for root, dirs, files in os.walk(f):
          for i in files:
            if i.endswith('.json'):
              fixtures.add(i.split('.')[0])
      except:
        pass # Silently ignore failures
    fixtures = sorted(fixtures)

    # Send to template
    return {'capacityconstrained': constraint & 4,
            'materialconstrained': constraint & 2,
            'leadtimeconstrained': constraint & 1,
            'fenceconstrained': constraint & 8,
            'scenarios': Scenario.objects.all(),
            'fixtures': fixtures,
            'openbravo': 'freppledb.openbravo' in settings.INSTALLED_APPS,
            'openerp': 'freppledb.openerp' in settings.INSTALLED_APPS,
            }
Beispiel #16
0
class Report(GridReport):
    """
  A list report to show problems.
  """

    template = "output/problem.html"
    title = _("Problem report")
    basequeryset = (
        Problem.objects
    )  # TODO .extra(select={'forecast': "select name from forecast where out_problem.owner like forecast.name || ' - %%'",})
    model = Problem
    permissions = (("view_problem_report", "Can view problem report"),)
    frozenColumns = 0
    editable = False
    multiselect = False
    help_url = "user-guide/user-interface/plan-analysis/problem-report.html"
    rows = (
        # . Translators: Translation included with Django
        GridFieldInteger("id", title=_("id"), key=True, editable=False, hidden=True),
        GridFieldText(
            "entity", title=_("entity"), editable=False, align="center"
        ),  # TODO choices=getEntities
        # . Translators: Translation included with Django
        GridFieldText(
            "name", title=_("name"), editable=False, align="center"
        ),  # TODO choices=getNames
        GridFieldText(
            "owner", title=_("owner"), editable=False, extra='"formatter":probfmt'
        ),
        GridFieldText("description", title=_("description"), editable=False, width=350),
        GridFieldDateTime("startdate", title=_("start date"), editable=False),
        GridFieldDateTime("enddate", title=_("end date"), editable=False),
        GridFieldNumber("weight", title=_("weight"), editable=False),
    )
Beispiel #17
0
class UserList(GridReport):
    '''
  A list report to show users.
  '''
    template = 'common/userlist.html'
    title = _("User List")
    basequeryset = User.objects.all()
    model = User
    adminsite = 'admin'
    frozenColumns = 2
    multiselect = False

    rows = (GridFieldInteger('id', title=_('id'), key=True, formatter='user'),
            GridFieldText('username', title=_('username')),
            GridFieldText('email',
                          title=_('email address'),
                          formatter='email',
                          width=200),
            GridFieldText('first_name', title=_('first name')),
            GridFieldText('last_name', title=_('last name')),
            GridFieldBool('is_active', title=_('active')),
            GridFieldBool('is_superuser',
                          title=_('superuser status'),
                          width=120),
            GridFieldDateTime('date_joined',
                              title=_('date joined'),
                              editable=False),
            GridFieldDateTime('last_login',
                              title=_('last login'),
                              editable=False))
Beispiel #18
0
class DetailReport(GridReport):
  '''
  A list report to show flowplans.
  '''
  template = 'output/flowplan.html'
  title = _("Inventory detail report")
  model = FlowPlan
  permissions = (('view_inventory_report','Can view inventory report'),)
  frozenColumns = 0
  editable = False
  multiselect = False

  @ classmethod
  def basequeryset(reportclass, request, args, kwargs):
    if args and args[0]:
      return FlowPlan.objects.filter(thebuffer__exact=args[0]).extra(select={'operation_in': "select name from operation where out_operationplan.operation = operation.name",})
    else:
      return FlowPlan.objects.extra(select={'operation_in': "select name from operation where out_operationplan.operation = operation.name",})

  @classmethod
  def extra_context(reportclass, request, *args, **kwargs):
    return {'active_tab': 'plandetail'}

  rows = (
    GridFieldText('thebuffer', title=_('buffer'), key=True, formatter='buffer', editable=False),
    GridFieldText('operationplan__operation', title=_('operation'), formatter='operation', editable=False),
    GridFieldNumber('quantity', title=_('quantity'), editable=False),
    GridFieldDateTime('flowdate', title=_('date'), editable=False),
    GridFieldNumber('onhand', title=_('onhand'), editable=False),
    GridFieldBool('operationplan__locked', title=_('locked'), editable=False),
    GridFieldInteger('operationplan', title=_('operationplan'), editable=False),
    )
Beispiel #19
0
class UserList(GridReport):
  '''
  A list report to show users.
  '''
  #. Translators: Translation included with Django
  title = _("users")
  basequeryset = User.objects.all()
  model = User
  frozenColumns = 2
  multiselect = False
  permissions = (("change_user", "Can change user"),)

  rows = (
    #. Translators: Translation included with Django
    GridFieldInteger('id', title=_('id'), key=True, formatter='detail', extra="role:'common/user'"),
    #. Translators: Translation included with Django
    GridFieldText('username', title=_('username')),
    #. Translators: Translation included with Django
    GridFieldText('email', title=_('email address'), formatter='email', width=200),
    #. Translators: Translation included with Django
    GridFieldText('first_name', title=_('first name')),
    #. Translators: Translation included with Django
    GridFieldText('last_name', title=_('last name')),
    #. Translators: Translation included with Django
    GridFieldBool('is_active', title=_('active')),
    #. Translators: Translation included with Django
    GridFieldBool('is_superuser', title=_('superuser status'), width=120),
    #. Translators: Translation included with Django
    GridFieldDateTime('date_joined', title=_('date joined'), editable=False),
    #. Translators: Translation included with Django
    GridFieldDateTime('last_login', title=_('last login'), editable=False)
    )
Beispiel #20
0
class BucketDetailList(GridReport):
    """
  A list report to show dates.
  """

    title = _("bucket dates")
    basequeryset = BucketDetail.objects.all()
    model = BucketDetail
    frozenColumns = 2
    help_url = "user-guide/model-reference/bucket-dates.html"
    default_sort = (2, "asc", 1, "asc")
    rows = (
        GridFieldInteger("id", title=_("identifier"), key=True, hidden=True),
        GridFieldText(
            "bucket",
            title=_("bucket"),
            field_name="bucket__name",
            formatter="detail",
            extra='"role":"common/bucket"',
        ),
        GridFieldDateTime("startdate", title=_("start date")),
        GridFieldDateTime("enddate", title=_("end date")),
        GridFieldText("name", title=_("name")),
        GridFieldText("source", title=_("source")),
        GridFieldLastModified("lastmodified"),
    )
Beispiel #21
0
class UserList(GridReport):
    """
    A list report to show users.
    """

    title = _("users")
    basequeryset = User.objects.all()
    model = User
    frozenColumns = 2
    permissions = (("change_user", "Can change user"), )
    help_url = "user-interface/getting-around/user-permissions-and-roles.html"

    rows = (
        GridFieldInteger(
            "id",
            title=_("id"),
            key=True,
            formatter="admin",
            extra='"role":"common/user"',
        ),
        GridFieldText("username", title=_("username")),
        GridFieldText("email",
                      title=_("email address"),
                      formatter="email",
                      width=200),
        GridFieldText("first_name", title=_("first name")),
        GridFieldText("last_name", title=_("last name")),
        GridFieldBool("is_active", title=_("active")),
        GridFieldBool("is_superuser", title=_("superuser status"), width=120),
        GridFieldDateTime("date_joined",
                          title=_("date joined"),
                          editable=False),
        GridFieldDateTime("last_login", title=_("last login"), editable=False),
    )
Beispiel #22
0
class UserList(GridReport):
  '''
  A list report to show users.
  '''
  #. Translators: Translation included with Django
  title = _("users")
  basequeryset = User.objects.all()
  model = User
  frozenColumns = 2
  permissions = (("change_user", "Can change user"),)
  help_url = 'user-guide/user-interface/getting-around/user-permissions-and-roles.html'

  rows = (
    #. Translators: Translation included with Django
    GridFieldInteger('id', title=_('id'), key=True, formatter='admin', extra='"role":"common/user"'),
    #. Translators: Translation included with Django
    GridFieldText('username', title=_('username')),
    #. Translators: Translation included with Django
    GridFieldText('email', title=_('email address'), formatter='email', width=200),
    #. Translators: Translation included with Django
    GridFieldText('first_name', title=_('first name')),
    #. Translators: Translation included with Django
    GridFieldText('last_name', title=_('last name')),
    #. Translators: Translation included with Django
    GridFieldBool('is_active', title=_('active')),
    #. Translators: Translation included with Django
    GridFieldBool('is_superuser', title=_('superuser status'), width=120),
    #. Translators: Translation included with Django
    GridFieldDateTime('date_joined', title=_('date joined'), editable=False),
    #. Translators: Translation included with Django
    GridFieldDateTime('last_login', title=_('last login'), editable=False)
    )
Beispiel #23
0
class ReportList(GridReport):
    template = "admin/base_site_grid.html"
    title = _("custom reports")
    model = SQLReport
    help_url = "user-guide/user-interface/report-manager.html"
    frozenColumns = 1
    rows = (
        GridFieldInteger(
            "id",
            title=_("identifier"),
            key=True,
            formatter="detail",
            extra='"role":"reportmanager/sqlreport"',
        ),
        GridFieldText("name", title=_("name")),
        GridFieldText("description", title=_("description")),
        GridFieldText("sql", title=_("SQL query")),
        GridFieldBoolNullable("public", title=_("public")),
        GridFieldText(
            "user__username",
            title=_("user"),
            editable=False,
            formatter="detail",
            extra='"role":"common/user"',
        ),
        GridFieldText("source", title=_("source")),
        GridFieldLastModified("lastmodified"),
    )

    @classmethod
    def basequeryset(reportclass, request, *args, **kwargs):
        return SQLReport.objects.filter(Q(user=request.user) | Q(public=True))
Beispiel #24
0
def getAttributeFields(model, related_name_prefix=None, initially_hidden=False):
  '''
  Return report fields for all attributes of a given model.
  '''
  from freppledb.common.report import GridFieldText, GridFieldBool, GridFieldNumber
  from freppledb.common.report import GridFieldInteger, GridFieldDate, GridFieldDateTime
  from freppledb.common.report import GridFieldDuration, GridFieldTime
  result = []
  for field_name, label, fieldtype in _register.get("%s.%s" % (model.__module__, model.__name__), []):
    if related_name_prefix:
      field_name = "%s__%s" % (related_name_prefix, field_name)
      label = "%s - %s" % (related_name_prefix.split('__')[-1], label)
    else:
      label = "%s - %s" % (model.__name__, label)
    if fieldtype == 'string':
      result.append( GridFieldText(field_name, title=label, initially_hidden=initially_hidden) )
    elif fieldtype == 'boolean':
      result.append( GridFieldBool(field_name, title=label, initially_hidden=initially_hidden) )
    elif fieldtype == 'number':
      result.append( GridFieldNumber(field_name, title=label, initially_hidden=initially_hidden) )
    elif fieldtype == 'integer':
      result.append( GridFieldInteger(field_name, title=label, initially_hidden=initially_hidden) )
    elif fieldtype == 'date':
      result.append( GridFieldDate(field_name, title=label, initially_hidden=initially_hidden) )
    elif fieldtype == 'datetime':
      result.append( GridFieldDateTime(field_name, title=label, initially_hidden=initially_hidden) )
    elif fieldtype == 'duration':
      result.append( GridFieldDuration(field_name, title=label, initially_hidden=initially_hidden) )
    elif fieldtype == 'time':
      result.append( GridFieldTime(field_name, title=label, initially_hidden=initially_hidden) )
    else:
      raise Exception("Invalid attribute type '%s'." % fieldtype)
  return result
Beispiel #25
0
class GroupList(GridReport):
    """
  A list report to show groups.
  """

    # . Translators: Translation included with Django
    title = _("groups")
    basequeryset = Group.objects.all()
    model = Group
    frozenColumns = 1
    permissions = (("change_group", "Can change group"), )
    help_url = (
        "user-guide/user-interface/getting-around/user-permissions-and-roles.html"
    )

    rows = (
        GridFieldInteger(
            "id",
            title=_("identifier"),
            key=True,
            formatter="detail",
            extra='"role":"auth/group"',
        ),
        # . Translators: Translation included with Django
        GridFieldText("name", title=_("name"), width=200),
    )
Beispiel #26
0
class BaseReport(GridReport):
    """
  A list report to show constraints.
  """

    template = "output/constraint.html"
    title = _("Constraint report")
    basequeryset = Constraint.objects.all()
    model = Constraint
    permissions = (("view_constraint_report", "Can view constraint report"),)
    frozenColumns = 0
    editable = False
    multiselect = False
    help_url = "user-interface/plan-analysis/constraint-report.html"
    detail_post_title = _("constrained demand")
    detailmodel = None
    rows = (
        GridFieldInteger("id", title=_("id"), key=True, editable=False, hidden=True),
        GridFieldText(
            "demand",
            title=_("demand"),
            editable=False,
            formatter="detail",
            extra='"role":"input/demand"',
        ),
        GridFieldText(
            "entity", title=_("entity"), editable=False, width=80, align="center"
        ),
        GridFieldText(
            "name", title=_("name"), editable=False, width=100, align="center"
        ),
        GridFieldText(
            "owner", title=_("owner"), editable=False, extra='"formatter":probfmt'
        ),
        GridFieldText("description", title=_("description"), editable=False, width=350),
        GridFieldDateTime("startdate", title=_("start date"), editable=False),
        GridFieldDateTime("enddate", title=_("end date"), editable=False),
        GridFieldNumber("weight", title=_("weight"), editable=False),
    )

    @classmethod
    def extra_context(reportclass, request, *args, **kwargs):
        if args and args[0] and reportclass.detailmodel:
            request.session["lasttab"] = "constraint"
            if (
                reportclass.detailmodel._meta.model_name == "buffer"
                and " @ " not in args[0]
            ):
                b = Buffer.objects.get(id=args[0])
                bufferName = b.item.name + " @ " + b.location.name
            return {
                "active_tab": "constraint",
                "title": force_text(reportclass.detailmodel._meta.verbose_name)
                + " "
                + (bufferName if "bufferName" in vars() else args[0]),
                "post_title": reportclass.detail_post_title,
            }
        else:
            return {"active_tab": "constraint"}
Beispiel #27
0
class ItemList(GridReport):
    title = _("items")
    basequeryset = Item.objects.all()
    model = Item
    frozenColumns = 1
    editable = True
    help_url = "modeling-wizard/master-data/items.html"
    message_when_empty = Template("""
        <h3>Define items</h3>
        <br>
        A basic piece of master data is the list of items to plan.<br>
        End products, intermediate products and raw materials all need to be defined.<br>
        <br><br>
        <div role="group" class="btn-group.btn-group-justified">
        <a href="{{request.prefix}}/data/input/item/add/" class="btn btn-primary">Create a single item<br>in a form</a>
        <a href="{{request.prefix}}/wizard/load/production/?currentstep=1" class="btn btn-primary">Wizard to upload items<br>from a spreadsheet</a>
        </div>
        <br>
        """)

    rows = (
        GridFieldHierarchicalText(
            "name",
            title=_("name"),
            key=True,
            formatter="detail",
            extra='"role":"input/item"',
            model=Item,
        ),
        GridFieldText("description", title=_("description")),
        GridFieldText("category", title=_("category"), initially_hidden=True),
        GridFieldText("subcategory",
                      title=_("subcategory"),
                      initially_hidden=True),
        GridFieldText(
            "owner",
            title=_("owner"),
            field_name="owner__name",
            formatter="detail",
            extra='"role":"input/item"',
        ),
        GridFieldCurrency("cost", title=_("cost")),
        GridFieldNumber("weight", title=_("weight"), initially_hidden=True),
        GridFieldNumber("volume", title=_("volume"), initially_hidden=True),
        GridFieldText("uom", title=_("unit of measure"),
                      initially_hidden=True),
        GridFieldInteger("periodofcover",
                         title=_("period of cover"),
                         initially_hidden=True),
        GridFieldChoice("type",
                        title=_("type"),
                        choices=Item.types,
                        initially_hidden=True),
        GridFieldText("source", title=_("source"), initially_hidden=True),
        GridFieldLastModified("lastmodified"),
    )
Beispiel #28
0
class DetailReport(GridReport):
    '''
  A list report to show loadplans.
  '''
    template = 'output/loadplan.html'
    title = _("Resource detail report")
    model = LoadPlan
    permissions = (("view_resource_report", "Can view resource report"), )
    frozenColumns = 0
    editable = False
    multiselect = False

    @classmethod
    def basequeryset(reportclass, request, args, kwargs):
        if args and args[0]:
            return LoadPlan.objects.filter(theresource__exact=args[0]).select_related() \
              .extra(select={'operation_in': "select name from operation where out_operationplan.operation = operation.name"})
        else:
            return LoadPlan.objects.select_related() \
              .extra(select={'operation_in': "select name from operation where out_operationplan.operation = operation.name"})

    @classmethod
    def extra_context(reportclass, request, *args, **kwargs):
        return {'active_tab': 'plandetail'}

    rows = (
        GridFieldText('theresource',
                      title=_('resource'),
                      key=True,
                      formatter='resource',
                      editable=False),
        GridFieldText('operationplan__operation',
                      title=_('operation'),
                      formatter='operation',
                      editable=False),
        GridFieldDateTime('startdate', title=_('start date'), editable=False),
        GridFieldDateTime('enddate', title=_('end date'), editable=False),
        GridFieldNumber('operationplan__quantity',
                        title=_('operationplan quantity'),
                        editable=False),
        GridFieldNumber('quantity', title=_('load quantity'), editable=False),
        GridFieldNumber('operationplan__criticality',
                        title=_('criticality'),
                        editable=False),
        GridFieldBool('operationplan__locked',
                      title=_('locked'),
                      editable=False),
        GridFieldNumber('operationplan__unavailable',
                        title=_('unavailable'),
                        editable=False),
        GridFieldInteger('operationplan',
                         title=_('operationplan'),
                         editable=False),
        GridFieldText('setup', title=_('setup'), editable=False),
    )
Beispiel #29
0
class CommentList(GridReport):
    """
    A list report to display all comments.
    """

    template = "common/commentlist.html"
    title = _("comments")
    basequeryset = Comment.objects.all()
    model = Comment
    editable = False
    multiselect = False
    frozenColumns = 0
    help_url = "user-interface/getting-around/comments.html"

    rows = (
        GridFieldInteger("id", title=_("identifier"), key=True),
        GridFieldLastModified("lastmodified"),
        GridFieldText(
            "user",
            title=_("user"),
            field_name="user__username",
            editable=False,
            align="center",
            width=80,
        ),
        GridFieldText(
            "model",
            title=_("model"),
            field_name="content_type__model",
            editable=False,
            align="center",
        ),
        GridFieldText(
            "object_pk",
            title=_("object id"),
            field_name="object_pk",
            editable=False,
            align="center",
            extra='"formatter": objectfmt',
        ),
        GridFieldText(
            "attachment",
            title=_("attachment"),
            width=50,
            editable=False,
            align="center",
            extra='"formatter": attachment',
        ),
        GridFieldText("comment", title=_("comment"), width=400,
                      editable=False),
        GridFieldText("app",
                      title="app",
                      hidden=True,
                      field_name="content_type__app_label"),
    )
Beispiel #30
0
class ResourceSkillList(GridReport):
    title = _("resource skills")
    basequeryset = ResourceSkill.objects.all()
    model = ResourceSkill
    frozenColumns = 1
    help_url = "model-reference/resource-skills.html"

    rows = (
        GridFieldInteger(
            "id",
            title=_("identifier"),
            key=True,
            formatter="detail",
            extra='"role":"input/resourceskill"',
        ),
        GridFieldHierarchicalText(
            "resource",
            title=_("resource"),
            field_name="resource__name",
            formatter="detail",
            extra='"role":"input/resource"',
            model=Resource,
        ),
        GridFieldText(
            "skill",
            title=_("skill"),
            field_name="skill__name",
            formatter="detail",
            extra='"role":"input/skill"',
        ),
        GridFieldDateTime("effective_start",
                          title=_("effective start"),
                          initially_hidden=True),
        GridFieldDateTime("effective_end",
                          title=_("effective end"),
                          initially_hidden=True),
        GridFieldInteger("priority",
                         title=_("priority"),
                         initially_hidden=True),
        GridFieldText("source", title=_("source"), initially_hidden=True),
        GridFieldLastModified("lastmodified"),
    )