Пример #1
0
                               codename=codename,
                               changelogs_dict=changelogs_dict,
                               download_stats=download_stats)


class Updates(object):
    @controller.publish
    @controller.set_cache_expires(secs=0)
    def default(self, *args, **kwargs):
        """ 
        @summary: handles the following urls:
            http://base_url/updates/distribution/release/
            with the following keywords:
                q = seach keyword
                page = starting page
                category = apps from category
            Or to check the latest update for a specific releasE:
                http://base_url/updates/distribution/release/appname            
        """
        argc = len(args)
        if argc != 2:
            controller.http_redirect(controller.base_url()+"/updates/Ubuntu/"\
                                     +controller.current_release)
        distro = args[0]
        release = args[1]

        return updates_page(distro, release, **kwargs)


controller.attach(Updates(), "/updates")
Пример #2
0
        if User.query.filter_by(email=email).first():
            return serve_template("register.html" \
         , user_email_exists=True, submit=True)
        authkey = userinfo.generate_auth_key()
        password = userinfo.md5pass(password1)
        # Clean the password fields - security
        password1 = None
        password2 = None
        # Insert the new user
        new_user = User(\
         username = name, \
         email = email, \
         password = password, \
         authkey = authkey, \
         auth = 0, \
         t_register = datetime.now(), \
         t_login = datetime.now(), \
         t_seen = datetime.now() )
        sender = apt_portal.get_config("mail", "register_sender")
        template.sendmail("register.mail" \
         , sender = sender \
         , destination = email \
         , username = name \
         , authkey = authkey \
         , sitename = "localhost" \
        )
        return template.render("register.html", submit=True)


controller.attach(Register_View(), "/register")
Пример #3
0
            , changelogs_dict = changelogs_dict
            , download_stats=download_stats
    )

class Updates(object):
       
    @controller.publish
    @controller.set_cache_expires(secs=0)
    def default(self, *args, **kwargs):
        """ 
        @summary: handles the following urls:
            http://base_url/updates/distribution/release/
            with the following keywords:
                q = seach keyword
                page = starting page
                category = apps from category
            Or to check the latest update for a specific releasE:
                http://base_url/updates/distribution/release/appname            
        """
        argc = len(args)
        if argc != 2:
            controller.http_redirect(controller.base_url()+"/updates/Ubuntu/"\
                                     +controller.current_release)
        distro = args[0]
        release = args[1]

        return updates_page(distro, release, **kwargs)


controller.attach(Updates(), "/updates")
Пример #4
0
from apt_portal import controller, template
from base.models.sponsor import Sponsor
from sqlalchemy import desc
import datetime


class Sponsors(object):
    @controller.publish
    def index(self):
        maxval = 10
        # Filter by no enddate or enddate in the future
        sponsors = Sponsor.query.order_by(desc(Sponsor.ammount)).all()
        # was unable to do it in the query. So manual filtering here.
        sponsors2 = []
        for sponsor in sponsors:
            # somehow the datetime comparison did not work. So parse the string as date (e.g. '28-02-2016')
            if (sponsor.enddate is None) or (datetime.datetime.now() <=
                                             datetime.datetime.strptime(
                                                 sponsor.enddate, '%d-%m-%Y')):
                sponsors2.append(sponsor)
        sponsors = sponsors2
        for sponsor in sponsors:
            if sponsor.ammount > maxval:
                maxval = sponsor.ammount
        return template.render("sponsors.html",
                               sponsors=sponsors,
                               maxval=maxval)


controller.attach(Sponsors(), "/sponsors")
Пример #5
0
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
@author: João Pinto <joao.pinto at getdeb.net>
"""

from apt_portal import controller, template


class Install:
    @controller.publish
    def default(self, *args):
        if len(args) < 1:
            return "Invalid parameter count"
        pck_name = args[0]
        if len(args) > 1:
            pck_version = args[1]
        return template.render("install.html", package_name=pck_name)


controller.attach(Install(), "/install")
Пример #6
0
            newheight = int(size[1])
            newwidth = int(width * (newheight / float(height)))
        size = newwidth, newheight
        # Resize and save the image
        im.thumbnail(size, Image.ANTIALIAS)
        im.save(thumb_filename)
        return "/" + return_thumb

    @controller.publish
    def change_category(self, action, name):
        """ Add/Del a category """
        if not userinfo.is_admin():
            controller.http_error(403)
        if action == "Add":
            appcat = ApplicationsCategory(name=name)
        else:
            appcat = ApplicationsCategory.query.filter_by(name=name).first()
            if appcat:
                appcat.delete()
        try:
            database.commit()
        except IntegrityError as e:
            pass

    @controller.publish
    def default(self, **args):
        print args


controller.attach(AppInfo(), "/appinfo")
Пример #7
0
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
@author: João Pinto <joao.pinto at getdeb.net>
"""

from apt_portal import controller, template
from base.modules import sponsors


class Welcome(object):
    @controller.publish
    def index(self):
        (sponsor, sponsor_total) = sponsors.get_sponsor()
        return template.render("welcome.html",
                               sponsor=sponsor,
                               sponsor_total=sponsor_total)


controller.attach(Welcome(), "/welcome")
Пример #8
0
        
        if User.query.filter_by(email = email).first():
            return serve_template("register.html" \
        	, user_email_exists=True, submit=True)        
        authkey = userinfo.generate_auth_key()
        password = userinfo.md5pass(password1)
        # Clean the password fields - security
        password1 = None
        password2 = None
        # Insert the new user
        new_user = User(\
        	username = name, \
        	email = email, \
        	password = password, \
        	authkey = authkey, \
        	auth = 0, \
        	t_register = datetime.now(), \
        	t_login = datetime.now(), \
        	t_seen = datetime.now() )
        sender = apt_portal.get_config("mail", "register_sender")
        template.sendmail("register.mail" \
        	, sender = sender \
        	, destination = email \
        	, username = name \
        	, authkey = authkey \
        	, sitename = "localhost" \
        )
        return template.render("register.html", submit=True)

controller.attach(Register_View(), "/register") 
Пример #9
0
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
@author: João Pinto <joao.pinto at getdeb.net>
"""

from apt_portal import controller
from base.models.user import User
from base.modules import userinfo

class Auth(object):
	@controller.publish
	def index(self, user = None, key = None):
		if not user or not key:
			return "Direct access is not allowed"
		user = User.query.filter_by(username = user, authkey = key).first()
		if user:
			user.auth = 1
			user.authkey = None
			userinfo.set_login_sesion_info(user)		
			controller.http_redirect(controller.base_url()+ "/welcome/")	
            
		return "Auth key or user are no longer valid!"

controller.attach(Auth(), "/auth") 
Пример #10
0
    def default(self, *args):
        if len(args) < 1:
            controller.http_redirect(controller.base_url())
        app_name = args[0].replace('+',' ')        
        application = Application.query.filter_by(name = app_name).first()
        if not application:
            application = Application.query.filter_by(\
                source_package = app_name).first()
        if not application:
            controller.http_redirect(controller.base_url())            
            
        # Get dict of the latest version for each distro release
        last_version_dict = {}        
        last_package = None    
        for plist in PackageList.query.all():
            if plist.suite.endswith('-testing'):
                continue
            package = Package.query.filter(and_(Package.lists.any(id=plist.id), 
                or_(Package.package==application.source_package, Package.source==application.source_package),
                Package.install_class=='M'))\
                .order_by(desc(Package.last_modified)).first()
            if package:
                last_version_dict[plist.version] = package.version
                last_package = package  
        return template.render("software.html", app=application,
                               last_version_dict=last_version_dict, 
                               package=last_package)
    
controller.attach(Software(), "/app") 
controller.attach(Software(), "/software") 
Пример #11
0
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
@author: João Pinto <joao.pinto at getdeb.net>
"""
from apt_portal import controller, template
from base.models.sponsor import Sponsor
from sqlalchemy import desc

class Sponsors(object):
	@controller.publish
	def index(self):
		maxval = 10
		sponsors = Sponsor.query.order_by(desc(Sponsor.ammount)).all()
		for sponsor in sponsors:
			if sponsor.ammount > maxval:
				maxval =  sponsor.ammount
		return template.render("sponsors.html"
			, sponsors = sponsors
			, maxval = maxval
			)
controller.attach(Sponsors(), "/sponsors") 
Пример #12
0
    def index(self, name=None, password = None, referer=None):
        if name: # submitting
            user = User.query.filter_by(username = name).first()
            if user and user.password == userinfo.md5pass(password, user.password):
                if user.auth == 1:
                    userinfo.set_login_sesion_info(user)
                    if referer:
                        controller.http_redirect(referer)
                    else:
                        controller.http_redirect(controller.base_url()+'/welcome/')
                else:
                    return template.render("login.html" 
                        , error_reason = "auth" 
                        , referer = referer 
                        )                    
            else:                
                return template.render("login.html"
                    , error_reason = "failed" 
                    , referer = referer 
                    )
        else:
            referer = controller.get_header('Referer')
            if not referer:
                referer = controller.base_url()+"/welcome/"
            return template.render("login.html"
                , hide_login_register = True
                , referer = referer
                , error_reason = None)
                
controller.attach(Login(), "/login")
Пример #13
0
from apt_portal import controller, template
from base.modules import userinfo

class Contact(object):
    @controller.publish
    def index(self, name = None, email = None, comment = None):
        if not name:
            return template.render("contact.html")
        # server side input validation
        if not email:
            return "Email is missing"
        if not comment or len(comment)<10:
            return "Comment is missing"
        if not userinfo.validateEmail(email):            
            return "Invalid email"  
        referer = controller.get_header('Referer')
        if not referer or not referer.startswith(controller.base_url()):
            return "Not Allowed"		
        contact_recipient = apt_portal.get_config("mail", "contact_recipient")
        id = int(time.time())
        template.sendmail('contact.mail'\
    		, sender = '"%s" <%s>' % (name, email)
    		, destination = contact_recipient
    		, comment = comment
            , app_name = apt_portal.app_name
            , id = id
    	)  
        return template.render("contact.html", contact_received=1)

controller.attach(Contact(), "/contact") 
Пример #14
0
 
    (C) Copyright 2009, APT-Portal Developers
    https://launchpad.net/~apt-portal-devs

@license:
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
@author: João Pinto <joao.pinto at getdeb.net>
"""

from apt_portal import controller

class LogOut(object):
	@controller.publish
	def index(self,):		
		controller.delete_session()
		raise controller.http_redirect(controller.base_url()+'/welcome')            		

controller.attach(LogOut(), "/logout")
Пример #15
0
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
@author: João Pinto <joao.pinto at getdeb.net>
"""

from apt_portal import controller, template

class Install:
	@controller.publish
	def default(self, *args):
		if len(args) < 1:
			return "Invalid parameter count"
		pck_name = args[0]
		if len(args) > 1:
			pck_version = args[1]
		return template.render("install.html", package_name = pck_name)		

controller.attach(Install(), "/install")

Пример #16
0
                source_package = app_name).first()
        if not application:
            controller.http_redirect(controller.base_url())

        # Get dict of the latest version for each distro release
        last_version_dict = {}
        downloads = {}
        last_package = None
        for plist in PackageList.query.all():
            if plist.suite.endswith('-testing'):
                continue
            package = Package.query.filter(and_(Package.lists.any(id=plist.id),
                or_(Package.package==application.source_package, Package.source==application.source_package),
                Package.install_class=='M'))\
                .order_by(desc(Package.last_modified)).first()
            if package:
                last_version_dict[plist.version] = package.version
                downloads[upstreamVersion(
                    package.version)] = package.download_count
                last_package = package
        return template.render("software.html",
                               app=application,
                               last_version_dict=last_version_dict,
                               downloads=downloads,
                               package=last_package)


controller.attach(Software(), "/app")
controller.attach(Software(), "/game")
controller.attach(Software(), "/software")
Пример #17
0
				, target_packagelist = target_packagelist \
				, repository_list = repository_list \
				, package_id = package_id \
				, source_list_id = source_list_id \
				, target_list = target_list \
				, asking = True \
				)
		source_package = package.source or package.package
		user = userinfo.find_user()
		action = "%s %s %s %s %s %s" % (user.email, 'copy' \
			, target_packagelist.suite, source_packagelist.suite, source_package, package.version)

		time_now = time.strftime("%Y%m%d.%H%M%S", time.localtime())
		filename = "%s_%s_%s" % (source_package, package.version, time_now)
		full_repos_cmd_dir  = os.path.join(apt_portal.base_dir, '..', repos_commands_dir)
		if not os.path.isdir(full_repos_cmd_dir):
			return "%s directory is not available, " \
				"repository commands are not supported" % \
				full_repos_cmd_dir
		os.umask(002)
		f = open(os.path.join(full_repos_cmd_dir, filename), 'w')
		os.umask(022)
		f.write(action)
		f.close()
		return template.render("package_copy.html" \
			, ticket_name = filename \
			, asking = False \
			)

controller.attach(Packages(), "/packages")
Пример #18
0
             , package_id = package_id \
             , source_list_id = source_list_id \
             , target_list = target_list \
             , asking = True \
             )
        source_package = package.source or package.package
        user = userinfo.find_user()
        action = "%s %s %s %s %s %s" % (user.email, 'copy' \
         , target_packagelist.suite, source_packagelist.suite, source_package, package.version)

        time_now = time.strftime("%Y%m%d.%H%M%S", time.localtime())
        filename = "%s_%s_%s" % (source_package, package.version, time_now)
        full_repos_cmd_dir = os.path.join(apt_portal.base_dir, '..',
                                          repos_commands_dir)
        if not os.path.isdir(full_repos_cmd_dir):
            return "%s directory is not available, " \
             "repository commands are not supported" % \
             full_repos_cmd_dir
        os.umask(002)
        f = open(os.path.join(full_repos_cmd_dir, filename), 'w')
        os.umask(022)
        f.write(action)
        f.close()
        return template.render("package_copy.html" \
         , ticket_name = filename \
         , asking = False \
         )


controller.attach(Packages(), "/packages")
Пример #19
0
    https://launchpad.net/~apt-portal-devs

@license:
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
@author: João Pinto <joao.pinto at getdeb.net>
"""

from apt_portal import controller, template
from base.modules import sponsors

class Welcome(object):
	@controller.publish
	def index(self):
		(sponsor, sponsor_total) = sponsors.get_sponsor()
		return template.render("welcome.html", sponsor = sponsor
							   , sponsor_total = sponsor_total)

controller.attach(Welcome(), "/welcome") 
Пример #20
0
@copyright:
 
    (C) Copyright 2009, APT-Portal Developers
    https://launchpad.net/~apt-portal-devs

@license:
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
@author: Joᅢᆪo Pinto <joao.pinto at getdeb.net>
"""

from apt_portal import controller, template

class About(object):
    @controller.publish
    def index(self):
        return template.render("about.html")

controller.attach(About(), "/about")