예제 #1
0
def createReportPermissions(app, created_models, verbosity, db=DEFAULT_DB_ALIAS, **kwargs):
  # Create the report permissions for the single menu instance we know about.
  if db == DEFAULT_DB_ALIAS:
    appname = app.__name__.replace(".models","")
    from freppledb.menu import menu
    menu.createReportPermissions(appname)
    from freppledb.common.dashboard import Dashboard
    Dashboard.createWidgetPermissions(appname)
예제 #2
0
def createExtraPermissions(sender, using=DEFAULT_DB_ALIAS, **kwargs):
    if using != DEFAULT_DB_ALIAS:
        return
    # Create the report permissions for the single menu instance we know about.
    from freppledb.menu import menu
    menu.createReportPermissions(sender.name)
    # Create widget permissions
    from freppledb.common.dashboard import Dashboard
    Dashboard.createWidgetPermissions(sender.name)
예제 #3
0
파일: __init__.py 프로젝트: frePPLe/frePPLe
def createExtraPermissions(sender, using=DEFAULT_DB_ALIAS, **kwargs):
  if using != DEFAULT_DB_ALIAS:
    return
  # Create the report permissions for the single menu instance we know about.
  from freppledb.menu import menu
  menu.createReportPermissions(sender.name)
  # Create widget permissions
  from freppledb.common.dashboard import Dashboard
  Dashboard.createWidgetPermissions(sender.name)
예제 #4
0
def createExtraPermissions(app, created_models, verbosity, db=DEFAULT_DB_ALIAS, **kwargs):
  if db != DEFAULT_DB_ALIAS:
    return
  # Create the report permissions for the single menu instance we know about.
  appname = app.__name__.replace(".models", "")
  from freppledb.menu import menu
  menu.createReportPermissions(appname)
  # Create widget permissions
  from freppledb.common.dashboard import Dashboard
  Dashboard.createWidgetPermissions(appname)
예제 #5
0
    def render(self, context):
        from freppledb.common.dashboard import Dashboard

        try:
            req = context["request"]
        except:
            return ""  # No request found in the context

        reg = Dashboard.buildList()
        context[self.varname] = [
            {
                "rowname": rown["rowname"],
                "cols": [
                    {
                        "width": i["width"],
                        "widgets": [
                            reg[j[0]](**j[1])
                            for j in i["widgets"]
                            if j[0] in reg and reg[j[0]].has_permission(req.user)
                        ],
                    }
                    for i in rown["cols"]
                ],
            }
            for rown in settings.DEFAULT_DASHBOARD
        ]
        return ""
예제 #6
0
 def render(self, context):
     from freppledb.common.dashboard import Dashboard
     try:
         req = context['request']
     except:
         return ''  # No request found in the context
     reg = Dashboard.buildList()
     mydashboard = req.user.getPreference("freppledb.common.cockpit",
                                          database=req.database)
     if not mydashboard:
         mydashboard = settings.DEFAULT_DASHBOARD
     context[self.hiddenvarname] = {i: j for i, j in reg.items()}
     context[self.varname] = []
     for i in mydashboard:
         cols = []
         for j in i['cols']:
             widgets = []
             for k in j['widgets']:
                 if k[0] in reg and reg[k[0]].has_permission(req.user):
                     widgets.append(reg[k[0]](**k[1]))
                     context[self.hiddenvarname].pop(k[0], None)
             cols.append({'width': j['width'], 'widgets': widgets})
         context[self.varname].append({
             'rowname': i['rowname'],
             'cols': cols
         })
     return ''
예제 #7
0
 def render(self, context):
   from freppledb.common.dashboard import Dashboard
   try: req = context['request']
   except: return ''  # No request found in the context
   reg = Dashboard.buildList()
   context[self.varname] = [ {'width': i['width'], 'widgets': [ reg[j[0]](**j[1]) for j in i['widgets'] if reg[j[0]].has_permission(req.user)]} for i in settings.DEFAULT_DASHBOARD ]
   return ''
예제 #8
0
 def render(self, context):
   from freppledb.common.dashboard import Dashboard
   try:
     req = context['request']
   except:
     return ''  # No request found in the context
   reg = Dashboard.buildList()
   context[self.varname] = [ {'width': i['width'], 'widgets': [ reg[j[0]](**j[1]) for j in i['widgets'] if reg[j[0]].has_permission(req.user)]} for i in settings.DEFAULT_DASHBOARD ]
   return ''
예제 #9
0
 def render(self, context):
   from freppledb.common.dashboard import Dashboard
   try:
     req = context['request']
   except:
     return ''  # No request found in the context
   reg = Dashboard.buildList()
   mydashboard = req.user.getPreference("freppledb.common.cockpit", database=req.database)
   if not mydashboard:
     mydashboard = settings.DEFAULT_DASHBOARD
   context[self.hiddenvarname] = { i: j for i, j in reg.items() }
   context[self.varname] = []
   for i in mydashboard:
     cols = []
     for j in i['cols']:
       widgets = []
       for k in j['widgets']:
         if k[0] in reg and reg[k[0]].has_permission(req.user):
           widgets.append(reg[k[0]](**k[1]))
           context[self.hiddenvarname].pop(k[0], None)
       cols.append( {'width': j['width'], 'widgets': widgets}  )
     context[self.varname].append( {'rowname': i['rowname'], 'cols': cols} )
   return ''
예제 #10
0
      '<table style="width:100%">',
      '<tr><th class="alignleft">%s</th><th>%s</th><th>%s</th><th>%s</th></tr>' % (
        capfirst(force_text(_("name"))), capfirst(force_text(_("due"))),
        capfirst(force_text(_("planned date"))), capfirst(force_text(_("delay")))
        )
      ]
    alt = False
    for prob in Problem.objects.using(db).filter(name='late', entity='demand').order_by('startdate', '-weight')[:limit]:
      result.append('<tr%s><td class="underline"><a href="%s/demandpegging/%s/">%s</a></td><td class="aligncenter">%s</td><td class="aligncenter">%s</td><td class="aligncenter">%s</td></tr>' % (
        alt and ' class="altRow"' or '', request.prefix, urlquote(prob.owner), escape(prob.owner), prob.startdate.date(), prob.enddate.date(), int(prob.weight)
        ))
      alt = not alt
    result.append('</table>')
    return HttpResponse('\n'.join(result))

Dashboard.register(LateOrdersWidget)


class ShortOrdersWidget(Widget):
  name = "short_orders"
  title = _("Short orders")
  tooltip = _("Shows orders that are not planned completely")
  permissions = (("view_problem_report", "Can view problem report"),)
  async = True
  # Note the gte filter lets pass "short" and "unplanned", and filters out
  # "late" and "early".
  url = '/problem/?entity=demand&name__gte=short&sord=asc&sidx=startdate'
  exporturl = True
  limit = 20

  def args(self):
예제 #11
0
파일: widget.py 프로젝트: dhl/frePPLe
  name = "welcome"
  title = _("Welcome")
  tooltip = _("Some links to get started")
  async = False

  def render(self, request=None):
    return _('''Welcome to frePPLe, the world's leading open source production planning tool!<br/><br/>
How to get started?
<ol><li>Start the <span class="underline"><a href="javascript:void(0);" onclick="tour.start('0,0,0'); return false;">guided tour</a></span></li>
<li>Check out the <span class="underline"><a href="/static/doc/index.html" target="_blank">documentation</a></span></li>
<li>Visit and join the <span class="underline"><a href="http://groups.google.com/group/frepple-users" target="_blank">user community</a></span></li>
<li><span class="underline"><a href="http://frepple.com/contact/" target="_blank">Contact us</a></span></li>
</ol>
''')

Dashboard.register(WelcomeWidget)


class NewsWidget(Widget):
  name = "news"
  title = _("News")
  tooltip = _("Show the latest news items from the frePPLe website")
  async = False

  def render(self, request=None):
    return '<iframe style="width:100%; border:none;" src="http://frepple.com/news-summary/"></iframe>'

Dashboard.register(NewsWidget)


class RecentActionsWidget(Widget):
예제 #12
0
파일: widget.py 프로젝트: gaohaian/frePPLe
# License along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

from django.middleware.csrf import get_token
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_text

from freppledb.common.dashboard import Dashboard, Widget


class ExecuteWidget(Widget):
  name = "execute"
  title = _("Execute")
  permissions = (("generate_plan", "Can generate plans"),)
  tooltip = _("Generate a constrained plan")
  async = False
  url = '/execute/'

  def render(self, request=None):
    from freppledb.common.middleware import _thread_locals
    return '''<div style="text-align:center">
      <form method="post" action="%s/execute/launch/frepple_run/">
      <input type="hidden" name="csrfmiddlewaretoken" value="%s">
      <input type="hidden" name="plantype" value="1"/>
      <input type="hidden" name="constraint" value="15"/>
      <input class="button" type="submit" value="%s"/>
      </form></div>
      ''' % (_thread_locals.request.prefix, get_token(_thread_locals.request), force_text(_("Create a plan")))

Dashboard.register(ExecuteWidget)
예제 #13
0
  title = _("Welcome")
  tooltip = _("Some links to get started")
  asynchronous = False

  def render(self, request=None):
    versionnumber = VERSION.split('.', 2)
    return _('''Welcome to frePPLe, the world's leading open source production planning tool!<br/><br/>
How to get started?
<ol><li>Start the <span class="underline"><a href="javascript:void(0);" onclick="tour.start('0,0,0'); return false;">guided tour</a></span></li>
<li>Check out the <span class="underline"><a href="%(docurl)s" target="_blank">documentation</a></span></li>
<li>Visit and join the <span class="underline"><a href="http://groups.google.com/group/frepple-users" target="_blank">user community</a></span></li>
<li><span class="underline"><a href="https://frepple.com/contact/" target="_blank">Contact us</a></span></li>
</ol>
''') % {'docurl': "https://frepple.com/docs/%s.%s/" % (versionnumber[0], versionnumber[1])}

Dashboard.register(WelcomeWidget)


class WizardWidget(Widget):
  name = "wizard"
  title = _("Modeling wizard")
  tooltip = _("Get started quick and easy to fill out the data tables")
  asynchronous = False
  url = '/wizard/'
  
  def render(self, request=None):
    from freppledb.common.middleware import _thread_locals
    try:
      db = _thread_locals.request.database or DEFAULT_DB_ALIAS
    except:
      db = DEFAULT_DB_ALIAS
예제 #14
0
파일: widget.py 프로젝트: allanzr/frepple
How to get started?
<ol>
<li>Check out the <span class="underline"><a href="%(docurl)s" target="_blank" rel="noopener">documentation</a></span></li>
<li>Visit and join the <span class="underline"><a href="http://groups.google.com/group/frepple-users" target="_blank" rel="noopener">user community</a></span></li>
<li><span class="underline"><a href="https://frepple.com/company/#contact" target="_blank" rel="noopener">Contact us</a></span></li>
</ol>
""") % {
                "docurl":
                "%s/docs/%s.%s/" % (settings.DOCUMENTATION_URL,
                                    versionnumber[0], versionnumber[1]),
                "prefix":
                prefix,
            })


Dashboard.register(WelcomeWidget)


class NewsWidget(Widget):
    name = "news"
    title = _("News")
    tooltip = _("Show the latest news items from the frePPLe website")
    asynchronous = False

    def render(self, request=None):
        return '<iframe style="width:100%; border:none;" src="https://frepple.com/news-summary/"></iframe>'


Dashboard.register(NewsWidget)

예제 #15
0
파일: widget.py 프로젝트: gaohaian/frePPLe
        for prob in Problem.objects.using(db).filter(name='late',
                                                     entity='demand').order_by(
                                                         'startdate',
                                                         '-weight')[:limit]:
            result.append(
                '<tr%s><td class="underline"><a href="%s/demandpegging/%s/">%s</a></td><td class="aligncenter">%s</td><td class="aligncenter">%s</td><td class="aligncenter">%s</td></tr>'
                %
                (alt and ' class="altRow"' or '', request.prefix,
                 urlquote(prob.owner), escape(prob.owner),
                 prob.startdate.date(), prob.enddate.date(), int(prob.weight)))
            alt = not alt
        result.append('</table>')
        return HttpResponse('\n'.join(result))


Dashboard.register(LateOrdersWidget)


class ShortOrdersWidget(Widget):
    name = "short_orders"
    title = _("Short orders")
    tooltip = _("Shows orders that are not planned completely")
    permissions = (("view_problem_report", "Can view problem report"), )
    async = True
    # Note the gte filter lets pass "short" and "unplanned", and filters out
    # "late" and "early".
    url = '/problem/?entity=demand&name__gte=short&sord=asc&sidx=startdate'
    exporturl = True
    limit = 20

    def args(self):
예제 #16
0
    title = _("Welcome")
    async = False

    def render(self, request=None):
        return _(
            '''Welcome to frePPLe, the world's leading open source production planning tool!<br/><br/>
How to get started?
<ol><li>Start the <span class="underline"><a href="javascript:void(0);" onclick="tour.start('0,0,0'); return false;">guided tour</a></span></li>
<li>Check out the <span class="underline"><a href="/static/doc/index.html" target="_blank">documentation</a></span></li>
<li>Visit and join the <span class="underline"><a href="http://groups.google.com/group/frepple-users" target="_blank">user community</a></span></li>
<li><span class="underline"><a href="http://frepple.com/contact/" target="_blank">Contact us</a></span></li>
</ol>
''')


Dashboard.register(WelcomeWidget)


class NewsWidget(Widget):
    name = "news"
    title = _("News")
    async = False

    def render(self, request=None):
        return '<iframe style="width:100%; border:none;" src="http://frepple.com/news-summary/"></iframe>'


Dashboard.register(NewsWidget)


class RecentActionsWidget(Widget):
예제 #17
0
  title = _("Welcome")
  tooltip = _("Some links to get started")
  asynchronous = False

  def render(self, request=None):
    versionnumber = VERSION.split('.', 2)
    return _('''Welcome to frePPLe, the world's leading open source production planning tool!<br/><br/>
How to get started?
<ol><li>Start the <span class="underline"><a href="javascript:void(0);" onclick="tour.start('0,0,0'); return false;">guided tour</a></span></li>
<li>Check out the <span class="underline"><a href="%(docurl)s" target="_blank">documentation</a></span></li>
<li>Visit and join the <span class="underline"><a href="http://groups.google.com/group/frepple-users" target="_blank">user community</a></span></li>
<li><span class="underline"><a href="https://frepple.com/contact/" target="_blank">Contact us</a></span></li>
</ol>
''') % {'docurl': "https://frepple.com/docs/%s.%s/" % (versionnumber[0], versionnumber[1])}

Dashboard.register(WelcomeWidget)


class WizardWidget(Widget):
  name = "wizard"
  title = _("Wizard to load your data")
  tooltip = _("Get started quick and easy to fill out the data tables")
  asynchronous = False
  url = '/wizard/'

  def render(self, request=None):
    from freppledb.common.middleware import _thread_locals
    try:
      db = _thread_locals.request.database or DEFAULT_DB_ALIAS
    except:
      db = DEFAULT_DB_ALIAS
예제 #18
0
            group by snapshot_date
            order by snapshot_date desc
            limit %s
            ) d
            order by snapshot asc
            """,
            (history, ),
        )
        for res in cursor.fetchall():
            result.append("<tr><td>%s</td><td>%.1f</td><td>%.1f</td></tr>" %
                          (escape(res[0]), res[1], res[2]))
        result.append("</table>")
        return HttpResponse("\n".join(result))


Dashboard.register(ArchivedBufferWidget)


class ArchivedDemandWidget(Widget):
    """
    This widget displays the total demand history based on the archived tables.
    """

    name = "archived_demand"
    title = _("Demand history")
    tooltip = _("Show the evolution of the open sales orders")
    asynchronous = True
    history = 12

    def args(self):
        return "?%s" % urlencode({"history": self.history})