Esempio n. 1
0
class InboxWidget(Widget):
    name = "inbox"
    title = _("inbox")
    tooltip = _("Unread messages from your inbox")
    url = "/inbox/"
    asynchronous = False
    limit = 10

    def render(self, request=None):
        from freppledb.common.middleware import _thread_locals

        try:
            db = _thread_locals.request.database or DEFAULT_DB_ALIAS
        except Exception:
            db = DEFAULT_DB_ALIAS
        notifs = (Notification.objects.using(db).filter(
            user=_thread_locals.request.user).order_by("-id").select_related(
                "comment", "user")[:self.limit])
        result = []
        result.append(
            '<div class="table-responsive"><table class="table table-condensed table-hover"><tbody>'
        )
        for notif in notifs:
            result.append(
                """<tr><td>
                <a class="underline" href="%s%s">%s</a>&nbsp;<span class="small">%s</span>
                <div class="small pull-right" data-toggle="tooltip" data-original-title="%s %s">%s%s&nbsp;&nbsp;%s</div>
                <br><p style="padding-left: 10px; display: inline-block;">%s</p>"""
                % (
                    _thread_locals.request.prefix,
                    notif.comment.getURL(),
                    notif.comment.object_repr,
                    escape(
                        capfirst(force_text(_(notif.comment.content_type.name))
                                 ) if notif.comment.content_type else ""),
                    escape(notif.comment.user.get_full_name()),
                    formats.date_format(notif.comment.lastmodified,
                                        "DATETIME_FORMAT"),
                    '<img class="avatar-sm" src="/uploads/%s">&nbsp;' % notif.
                    comment.user.avatar if notif.comment.user.avatar else "",
                    escape(notif.comment.user.username),
                    timesince(notif.comment.lastmodified),
                    escape(notif.comment.comment),
                ) + "</td></tr>")
        result.append("</tbody></table></div>")
        return "\n".join(result) if result else force_text(
            _("No unread messages!"))

    javascript = """
    var hasForecast = %s;
    var hasIP = %s;
    var version = '%s.%s';
    """ % (
        "true" if "freppledb.forecast" in settings.INSTALLED_APPS else "false",
        "true" if "freppledb.inventoryplanning" in settings.INSTALLED_APPS else
        "false",
        VERSION.split(".", 2)[0],
        VERSION.split(".", 2)[1],
    )
Esempio n. 2
0
class RecentCommentsWidget(Widget):
    name = "recent_comments"
    title = _("comments")
    tooltip = _("Display a list of recent comments")
    url = "/data/common/comment/?sord=desc&sidx=lastmodified"
    asynchronous = False
    limit = 10

    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
        cmts = (
            Comment.objects.using(db)
            .order_by("-lastmodified")
            .select_related("content_type", "user")[: self.limit]
        )
        result = []
        result.append(
            '<div class="table-responsive"><table class="table table-condensed table-hover"><tbody>'
        )
        for c in cmts:
            result.append(
                '<tr><td><a href="%s%s">%s</a>&nbsp;<span class="small">%s</span><div class="small" style="float: right;">%s&nbsp;&nbsp;%s</div><br><p style="padding-left: 10px; display: inline-block;">%s</p>'
                % (
                    _thread_locals.request.prefix,
                    c.get_admin_url(),
                    escape(c.object_pk),
                    escape(
                        capfirst(force_text(_(c.content_type.name)))
                        if c.content_type
                        else force_text(_("Unknown content"))
                    ),
                    escape(c.user.username if c.user else ""),
                    formats.date_format(c.lastmodified, "SHORT_DATETIME_FORMAT"),
                    escape(c.comment),
                )
                + "</td></tr>"
            )
        result.append("</tbody></table></div>")
        # . Translators: Translation included with Django
        return "\n".join(result) if result else force_text(_("None available"))

    javascript = """
    var hasForecast = %s;
    var hasIP = %s;
    var version = '%s.%s';
    """ % (
        "true" if "freppledb.forecast" in settings.INSTALLED_APPS else "false",
        "true" if "freppledb.inventoryplanning" in settings.INSTALLED_APPS else "false",
        VERSION.split(".", 2)[0],
        VERSION.split(".", 2)[1],
    )
Esempio n. 3
0
class RecentCommentsWidget(Widget):
    name = "recent_comments"
    title = _("comments")
    tooltip = _("Display a list of recent comments")
    url = '/data/common/comment/?sord=desc&sidx=lastmodified'
    asynchronous = False
    limit = 10

    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
        cmts = Comment.objects.using(db).order_by(
            '-lastmodified').select_related('content_type',
                                            'user')[:self.limit]
        result = []
        result.append(
            '<div class="table-responsive"><table class="table table-condensed"><tbody>'
        )
        for c in cmts:
            result.append(
                '<tr><td><a href="%s%s">%s</a>&nbsp;<span class="small">%s</span><div class="small" style="float: right;">%s&nbsp;&nbsp;%s</div></br><p style="padding-left: 10px; display: inline-block;">%s</p>'
                %
                (_thread_locals.request.prefix, c.get_admin_url(),
                 escape(c.object_pk),
                 escape(
                     capfirst(force_text(_(c.content_type.name))) if c.
                     content_type else force_text(_('Unknown content'))),
                 escape(c.user.username if c.user else ''),
                 formats.date_format(c.lastmodified, 'SHORT_DATETIME_FORMAT'),
                 escape(c.comment)) + '</td></tr>')
        result.append('</tbody></table></div>')
        #. Translators: Translation included with Django
        return '\n'.join(result) if result else force_text(_('None available'))

    javascript = '''
    var hasForecast = %s;
    var hasIP = %s;
    var version = '%s.%s';
    $(function() {
       wizard.updateWizard();
    });
    ''' % ('true' if 'freppledb.forecast' in settings.INSTALLED_APPS else
           'false', 'true' if 'freppledb.inventoryplanning'
           in settings.INSTALLED_APPS else 'false', VERSION.split(
               '.', 2)[0], VERSION.split('.', 2)[1])
Esempio n. 4
0
    def render(self, request=None):
        from freppledb.common.middleware import _thread_locals

        versionnumber = VERSION.split(".", 2)
        try:
            db = _thread_locals.request.database
            if not db or db == DEFAULT_DB_ALIAS:
                prefix = ""
            else:
                prefix = "/%s" % _thread_locals.request.database
        except Exception:
            prefix = ""
        return (
            _(
                """Welcome to the world's leading open source production planning tool!<br><br>
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,
            }
        )
Esempio n. 5
0
    def render(self, request=None):
        from freppledb.common.middleware import _thread_locals
        versionnumber = VERSION.split('.', 2)
        try:
            db = _thread_locals.request.database
            if not db or db == DEFAULT_DB_ALIAS:
                prefix = ''
            else:
                prefix = "/%s" % _thread_locals.request.database
        except:
            prefix = ''
        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" rel="noopener">documentation</a></span></li>
<li>Start building your own model using the <span class="underline"><a href="%(prefix)s/wizard/" target="_blank" rel="noopener">wizard</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/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
            }
Esempio n. 6
0
  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])}
Esempio n. 7
0
  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])}
Esempio n. 8
0
  def render(self, request=None):
    from freppledb.common.middleware import _thread_locals
    versionnumber = VERSION.split('.', 2)
    try:
      db = _thread_locals.request.database
      if not db or db == DEFAULT_DB_ALIAS:
        prefix = ''
      else:
        prefix = "/%s" % _thread_locals.request.database
    except:
      prefix = ''
    return _('''Welcome to 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" 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/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
  }
Esempio n. 9
0
def version_short():
    '''
  A simple tag returning the version of the frePPLe application.
  '''
    versionnumber = VERSION.split('.', 2)
    return '%s.%s' % (versionnumber[0], versionnumber[1])
Esempio n. 10
0
  report=freppledb.common.views.BucketDetailList, index=1300, model=BucketDetail
  )
menu.addItem(
  "admin", "comment admin", url="/data/common/comment/",
  report=freppledb.common.views.CommentList, index=1400, model=Comment
  )

# User maintenance
menu.addItem("admin", "users", separator=True, index=2000)
menu.addItem(
  "admin", "user admin", url="/data/common/user/",
  report=freppledb.common.views.UserList, index=2100, model=User
  )
menu.addItem(
  "admin", "group admin", url="/data/auth/group/",
  report=freppledb.common.views.GroupList, index=2200, permission="auth.change_group"
  )

# Help menu
menu.addItem("help", "hints", label=_('Show hints'), index=90, identifier="showHints",
  javascript='tour.displayHints($(this).hasClass("toggle-off"), false)')
menu.addItem("help", "tour", javascript="tour.start('0,0,0')", label=_('Guided tour'), index=100)
menu.addItem("help", "wizard", url="/wizard/", window=True, prefix=True, label=_('Path to unlock features'), index=200)
versionnumber = VERSION.split('.', 2)
docurl = "https://frepple.com/docs/%s.%s/" % (versionnumber[0], versionnumber[1])
#. Translators: Translation included with Django
menu.addItem("help", "documentation", url=docurl, label=_('Documentation'), window=True, prefix=False, index=300)
menu.addItem("help", "API", url="/api/", label=_('REST API help'), window=True, prefix=True, index=400)
menu.addItem("help", "website", url="https://frepple.com", window=True, label=_('frePPLe website'), prefix=False, index=500)
menu.addItem("help", "about", javascript="about_show()", label=_('About frePPLe'), index=600)
Esempio n. 11
0
def version_short():
    """
  A simple tag returning the version of the frePPLe application.
  """
    versionnumber = VERSION.split(".", 2)
    return "%s.%s" % (versionnumber[0], versionnumber[1])
Esempio n. 12
0
  "admin", "bucketdetail admin", url="/data/common/bucketdetail/",
  report=freppledb.common.views.BucketDetailList, index=1300, model=BucketDetail
  )
menu.addItem(
  "admin", "comment admin", url="/data/common/comment/",
  report=freppledb.common.views.CommentList, index=1400, model=Comment
  )

# User maintenance
menu.addItem("admin", "users", separator=True, index=2000)
menu.addItem(
  "admin", "user admin", url="/data/common/user/",
  report=freppledb.common.views.UserList, index=2100, model=User
  )
menu.addItem(
  "admin", "group admin", url="/data/auth/group/",
  report=freppledb.common.views.GroupList, index=2200, permission="auth.change_group"
  )

# Help menu
menu.addItem("help", "hints", label=_('Show hints'), index=90, identifier="showHints",
  javascript='tour.displayHints($(this).hasClass("toggle-off"), false)')
menu.addItem("help", "tour", javascript="tour.start('0,0,0')", label=_('Guided tour'), index=100)
versionnumber = VERSION.split('.', 2)
docurl = "%s/docs/%s.%s/index.html" % (settings.DOCUMENTATION_URL, versionnumber[0], versionnumber[1])
#. Translators: Translation included with Django
menu.addItem("help", "documentation", url=docurl, label=_('Documentation'), window=True, prefix=False, index=300)
menu.addItem("help", "API", url="/api/", label=_('REST API help'), window=True, prefix=True, index=400)
menu.addItem("help", "website", url="https://frepple.com", window=True, label=_('frePPLe website'), prefix=False, index=500)
menu.addItem("help", "about", javascript="about_show()", label=_('About frePPLe'), index=600)
Esempio n. 13
0
    permission="auth.change_group",
)

# Help menu
menu.addItem(
    "help",
    "hints",
    label=_("Show hints"),
    index=90,
    identifier="showHints",
    javascript='tour.displayHints($(this).hasClass("toggle-off"), false)',
)
menu.addItem(
    "help", "tour", javascript="tour.start('0,0,0')", label=_("Guided tour"), index=100
)
versionnumber = VERSION.split(".", 2)
docurl = "%s/docs/%s.%s/index.html" % (
    settings.DOCUMENTATION_URL,
    versionnumber[0],
    versionnumber[1],
)
# . Translators: Translation included with Django
menu.addItem(
    "help",
    "documentation",
    url=docurl,
    label=_("Documentation"),
    window=True,
    prefix=False,
    index=300,
)
Esempio n. 14
0
# User maintenance
menu.addItem("admin", "users", separator=True, index=2000)
menu.addItem(
    "admin", "user admin", url="/data/common/user/", report=freppledb.common.views.UserList, index=2100, model=User
)
menu.addItem(
    "admin", "group admin", url="/data/auth/group/", report=freppledb.common.views.GroupList, index=2200, model=Group
)

# Help menu
menu.addItem(
    "help",
    "hints",
    label=_("Show hints"),
    index=90,
    identifier="showHints",
    javascript='tour.displayHints($(this).hasClass("toggle-off"), false)',
)
menu.addItem("help", "tour", javascript="tour.start('0,0,0')", label=_("Guided tour"), index=100)
menu.addItem("help", "wizard", url="/wizard/", window=True, prefix=True, label=_("Wizard to load your data"), index=200)
versionnumber = VERSION.split(".", 2)
docurl = "https://frepple.com/docs/" + versionnumber[0] + "." + versionnumber[1] + "/"
# . Translators: Translation included with Django
menu.addItem("help", "documentation", url=docurl, label=_("Documentation"), window=True, prefix=False, index=300)
menu.addItem("help", "API", url="/api/", label=_("REST API help"), window=True, prefix=True, index=400)
menu.addItem(
    "help", "website", url="https://frepple.com", window=True, label=_("frePPLe website"), prefix=False, index=500
)
menu.addItem("help", "about", javascript="about_show()", label=_("About frePPLe"), index=600)
Esempio n. 15
0
def version_short():
  '''
  A simple tag returning the version of the frePPLe application.
  '''
  versionnumber = VERSION.split('.', 2)
  return versionnumber[0]+"."+versionnumber[1]