# 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)
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):
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)
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
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):
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):
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
'<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):
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})