Exemple #1
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,
            })
Exemple #2
0
def version_short():
    """
    A simple tag returning the version of the frePPLe application.
    """
    try:
        versionnumber = __version__.split(".", 2)
        return "%s.%s" % (versionnumber[0], versionnumber[1])
    except Exception:
        return "current"
Exemple #3
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 = list(
            Notification.objects.using(db).filter(
                user=_thread_locals.request.user).order_by(
                    "-id").select_related("comment", "user")[:self.limit])
        if not notifs:
            return """
              <div class="pull-left"><i class="fa fa-5x fa-trophy" style="color: gold"></i>&nbsp;&nbsp;</div>
              <h2>Congrats!</h2>
              Your inbox is empty.
              """
        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)

    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],
    )
Exemple #4
0
    model=User,
    admin=True,
)
menu.addItem(
    "admin",
    "group admin",
    url="/data/auth/group/",
    report=freppledb.common.views.GroupList,
    index=2200,
    permission="auth.change_group",
    admin=True,
)

# Help menu
try:
    versionnumber = __version__.split(".", 2)
    docurl = "%s/docs/%s.%s/index.html" % (
        settings.DOCUMENTATION_URL,
        versionnumber[0],
        versionnumber[1],
    )
except Exception:
    docurl = "%s/docs/current/index.html" % (settings.DOCUMENTATION_URL, )
menu.addItem(
    "help",
    "documentation",
    url=docurl,
    label=_("Documentation"),
    window=True,
    prefix=False,
    index=300,
Exemple #5
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])