Ejemplo n.º 1
0
    def get_current_admin_guide():
        module_name = request.blueprint

        admin_guide = Page.get_by_path('guides/admin/' + module_name)

        if not admin_guide or not ModuleAPI.can_write(module_name):
            admin_revision = PageRevision(None, None, None, None, None, None, None)
            if ModuleAPI.can_write(module_name):
                admin_revision.title = 'Er is geen admin handleiding beschikbaar voor ' +\
                    module_name
                if ModuleAPI.can_write('page'):
                    admin_revision.content = 'Voeg ' +\
                        '<a href="/edit/guides/admin/' + module_name + '"> hier </a>' +\
                        ' een admin handleiding toe.'
                else:
                    admin_revision.content = ''
            else:
                admin_revision.title = ''
                admin_revision.content = ''
        else:
            admin_revision = admin_guide.get_latest_revision()
            if ModuleAPI.can_write('page') and\
                    ModuleAPI.can_write(module_name):
                admin_revision.title += '<a href="/edit/guides/admin/' + module_name +\
                    '"> (bewerk) </a>'

        return admin_revision
Ejemplo n.º 2
0
    def get_current_admin_guide() -> PageRevision:
        module_name = request.blueprint
        if not module_name:
            admin_guide = None
            module_name = 'static'
        else:
            admin_guide = page_service.get_page_by_path(
                'guides/admin/' + module_name)

        if not admin_guide:
            admin_revision = PageRevision(None, None, None, None, None, None,
                                          None)
            admin_revision.title = \
                'Er is geen admin handleiding beschikbaar voor ' + \
                module_name
            if role_service.user_has_role(current_user, Roles.PAGE_WRITE):
                admin_revision.content = 'Voeg ' +\
                    '<a href="/edit/guides/admin/' + module_name +\
                    '"> hier </a> een admin handleiding toe.'
            else:
                admin_revision.content = ''

        else:
            admin_revision = admin_guide.get_latest_revision()
            if role_service.user_has_role(current_user, Roles.PAGE_WRITE):
                admin_revision.title += '<a href="/edit/guides/admin/' + \
                    module_name + '"> (bewerk) </a>'

        return admin_revision
Ejemplo n.º 3
0
    def get_current_user_guide() -> PageRevision:
        """Get the user guide for a specific module."""
        module_name = request.blueprint
        if not module_name:
            user_guide = None
            module_name = 'static'
        else:
            user_guide = page_service.get_page_by_path(
                'guides/user/' + module_name)

        if not user_guide:
            user_revision = PageRevision(None, None, None, None, None, None,
                                         None)
            user_revision.title = \
                'Er is geen user handleiding beschikbaar voor ' + module_name

            if role_service.user_has_role(current_user, Roles.PAGE_WRITE):
                user_revision.content = 'Voeg ' +\
                    '<a href="/edit/guides/user/' + module_name + \
                    '"> hier </a> een user handleiding toe.'
            else:
                user_revision.content = ''
        else:
            user_revision = user_guide.get_latest_revision()
            if role_service.user_has_role(current_user, Roles.PAGE_WRITE):
                user_revision.title += '<a href="/edit/guides/user/' +\
                    module_name + '"> (bewerk) </a>'

        return user_revision
Ejemplo n.º 4
0
    def get_current_user_guide():
        module_name = request.blueprint

        """ Get the user guide for a specific module """
        user_guide = Page.get_by_path('guides/user/' + module_name)

        if not user_guide:
            user_revision = PageRevision(None, None, None, None, None, None, None)
            user_revision.title = 'Er is geen user handleiding beschikbaar voor ' +\
                module_name

            if ModuleAPI.can_write('page') and\
                    ModuleAPI.can_write(module_name):
                user_revision.content = 'Voeg ' +\
                    '<a href="/edit/guides/user/' + module_name + '"> hier </a>' +\
                    ' een user handleiding toe.'
            else:
                user_revision.content = ''
        else:
            user_revision = user_guide.get_latest_revision()
            if ModuleAPI.can_write('page') and\
                    ModuleAPI.can_write(module_name):
                user_revision.title += '<a href="/edit/guides/user/' + module_name +\
                    '"> (bewerk) </a>'

        return user_revision
Ejemplo n.º 5
0
    def get_challenge_description():
        """ Get the description page for challenges """
        page = Page.get_by_path(Page.strip_path("challenge_description"))

        if not page:
            revision = PageRevision(None, None, None, None, None)
            revision.title = 'Not found!'
            revision.content = 'Description not found'
        else:
            revision = page.get_latest_revision()

        return revision
Ejemplo n.º 6
0
def get_revisions(data):
    pages = []
    revisions = []

    for path in data:
        if path == 'activities':
            revision = PageRevision(None, None, None, None, None, None, None)

            activities = Activity.query \
                .filter(Activity.end_time > datetime.now()) \
                .order_by(Activity.start_time.asc())
            revision.activity = \
                render_template('activity/view_simple.htm',
                                activities=activities.paginate(1, 4, False))

            revisions.append(revision)

            continue

        page = page_service.get_page_by_path(Page.strip_path(path))
        pages.append(page)

        if not page:
            revision = PageRevision(None, None, None, None, None, None, None)
            revision.title = _('Not found!')
            revision.content = _('Page not found')

            revisions.append(revision)

            continue

        revision = page.get_latest_revision()
        revision.test = path
        if not revision:
            return abort(500)

        revisions.append(revision)

    return revisions