Example #1
0
	def remove(self, package_id, list_id, confirm=None):
		""" Create a command to remove a package from the repository """
		if not userinfo.is_admin():
			controller.http_error(403)
		package_id	= long(package_id)
		list_id = long(list_id)
		package = Package.query.filter_by(id = package_id).first()
		packagelist = PackageList.query.filter_by(id = list_id).first()
		if not package:
			return "Package %d not found" % package_id
		if not packagelist:
			return "List %d not found" % list_id
		if confirm != "Y":
			return template.render("package_remove.html" \
				, package = package, packagelist = packagelist)
		source_package = package.source or package.package
		user = userinfo.find_user()
		action = "%s %s %s %s %s" % (user.email, 'remove' \
			, 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_remove.html" \
			, ticket_name = filename, confirm='Y')
Example #2
0
    def remove(self, package_id, list_id, confirm=None):
        """ Create a command to remove a package from the repository """
        if not userinfo.is_admin():
            controller.http_error(403)
        package_id = long(package_id)
        list_id = long(list_id)
        package = Package.query.filter_by(id=package_id).first()
        packagelist = PackageList.query.filter_by(id=list_id).first()
        if not package:
            return "Package %d not found" % package_id
        if not packagelist:
            return "List %d not found" % list_id
        if confirm != "Y":
            return template.render("package_remove.html" \
             , package = package, packagelist = packagelist)
        source_package = package.source or package.package
        user = userinfo.find_user()
        action = "%s %s %s %s %s" % (user.email, 'remove' \
         , 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_remove.html" \
         , ticket_name = filename, confirm='Y')
Example #3
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)
Example #4
0
    def copy(self, package_id, source_list_id, target_list):
        """ Create a command to copy a package to another repository """
        if not userinfo.is_admin():
            controller.http_error(403)

        package_id = long(package_id)
        source_list_id = long(source_list_id)
        package = Package.query.filter_by(id=package_id).first()
        source_packagelist = PackageList.query.filter_by(
            id=source_list_id).first()
        target_packagelist = PackageList.query.filter_by(
            suite=target_list).first()
        if not package:
            return "Package %d not found" % package_id
        if not source_packagelist:
            return "List %d not found" % list_id
        if target_list and not target_packagelist:
            return "Repository %s not found" % target_list
        repository_list = []
        for plist in PackageList.query.all():
            if plist.suite == source_packagelist.suite:
                continue
            if (plist.suite not in repository_list) and (plist.suite >= "t"):
                repository_list.append(plist.suite)
        if len(target_list) < 2:
            return template.render("package_copy.html" \
             , package = package \
             , source_packagelist = source_packagelist \
             , 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 \
         )
Example #5
0
	def copy(self, package_id, source_list_id, target_list):
		""" Create a command to copy a package to another repository """
		if not userinfo.is_admin():
			controller.http_error(403)

		package_id	= long(package_id)
		source_list_id = long(source_list_id)
		package = Package.query.filter_by(id = package_id).first()
		source_packagelist = PackageList.query.filter_by(id = source_list_id).first()
		target_packagelist = PackageList.query.filter_by(suite = target_list).first()
		if not package:
			return "Package %d not found" % package_id
		if not source_packagelist:
			return "List %d not found" % list_id
		if target_list and not target_packagelist:
			return "Repository %s not found" % target_list
		repository_list = []
		for plist in PackageList.query.all():
			if plist.suite == source_packagelist.suite:
				continue
			if ( plist.suite not in repository_list ) and ( plist.suite >= "t" ):
				repository_list.append(plist.suite)
		if len(target_list) < 2:
			return template.render("package_copy.html" \
				, package = package \
				, source_packagelist = source_packagelist \
				, 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 \
			)
Example #6
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)
Example #7
0
 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)
Example #8
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 = {}
        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)
Example #9
0
	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)		
Example #10
0
    def index(self, name=None, email=None, password1=None, password2=None):
        if not name:
            return template.render("register.html")
        # Server side validation
        if not userinfo.validateUsername(name):
            return "Invalid username"		
        if not email:
            return "Email is missing"
        if not password1:
            return "Password is missing"            
        if not userinfo.validateEmail(email): 
            return "Invalid email"

        if User.query.filter_by(username = name).first():
            return template.render("register.html" \
        		, user_already_exists=True, submit=True)
        
        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)
Example #11
0
    def index(self, name=None, email=None, password1=None, password2=None):
        if not name:
            return template.render("register.html")
        # Server side validation
        if not userinfo.validateUsername(name):
            return "Invalid username"
        if not email:
            return "Email is missing"
        if not password1:
            return "Password is missing"
        if not userinfo.validateEmail(email):
            return "Invalid email"

        if User.query.filter_by(username=name).first():
            return template.render("register.html" \
          , user_already_exists=True, submit=True)

        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)
Example #12
0
	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
			)
Example #13
0
 def edit(self, for_package_id = None, from_app_id = None):
     """ 
     Add/Edit an application record, after submission the browser
     will be redirected to the referer page
     """        
     if not userinfo.is_admin():
         controller.http_redirect(controller.base_url()+'/login/')
 
     # We need these to fill the combo box
     # do it here to avoid autoflush later
     categories = ApplicationsCategory.query.all()
     
     source_package = None
     application = None
     # the app info can be loaded from an app_id or for a package id
     if from_app_id:
         application = app_by_id(from_app_id)
         if not application:
             return "Application ID not found"
     elif for_package_id:
         package_id = for_package_id
         package = Package.query.filter_by(id = package_id).one()
         if not package:
             return "Package id %d not found" % package_id
         source_package = package.source or package.package
         
     if source_package: # we got a package hint
         application = Application.query.filter_by(\
             source_package = source_package).first()
 
     if not application: # app was not found, create new
         application = Application()
         application.source_package = source_package
 
     # Automatically set app name to source package
     # usefull hint on "for_package_id"                    
     if not application.name:
         application.name = source_package        
 
     # No changes here, save will be performed on edit_submit
     database.rollback()
     if sa_version.split(".") < ["0", "5", "0"]:
         database.clear()
     
     # Set the screenshot filename
     screenshot_filename = ""
     id = application.id
     if id:
         screenshot_filename = "/media/screens/%d/%d_t.png" % (id, id)            
     return template.render("app_edit.html" \
         , application = application \
         , categories = categories \
         , screenshot_filename = screenshot_filename \
     )
Example #14
0
    def edit(self, for_package_id=None, from_app_id=None):
        """ 
        Add/Edit an application record, after submission the browser
        will be redirected to the referer page
        """
        if not userinfo.is_admin():
            controller.http_redirect(controller.base_url() + '/login/')

        # We need these to fill the combo box
        # do it here to avoid autoflush later
        categories = ApplicationsCategory.query.all()

        source_package = None
        application = None
        # the app info can be loaded from an app_id or for a package id
        if from_app_id:
            application = app_by_id(from_app_id)
            if not application:
                return "Application ID not found"
        elif for_package_id:
            package_id = for_package_id
            package = Package.query.filter_by(id=package_id).one()
            if not package:
                return "Package id %d not found" % package_id
            source_package = package.source or package.package

        if source_package:  # we got a package hint
            application = Application.query.filter_by(\
                source_package = source_package).first()

        if not application:  # app was not found, create new
            application = Application()
            application.source_package = source_package

        # Automatically set app name to source package
        # usefull hint on "for_package_id"
        if not application.name:
            application.name = source_package

        # No changes here, save will be performed on edit_submit
        database.rollback()
        if sa_version.split(".") < ["0", "5", "0"]:
            database.clear()

        # Set the screenshot filename
        screenshot_filename = ""
        id = application.id
        if id:
            screenshot_filename = "/media/screens/%d/%d_t.png" % (id, id)
        return template.render("app_edit.html" \
            , application = application \
            , categories = categories \
            , screenshot_filename = screenshot_filename \
        )
Example #15
0
    def index(self, q=None):
        """
		The is the main page which presents the list of packages
		if no key (q) is specified only the packages needing an action
		are shown.
		"""
        if not userinfo.is_admin():
            controller.http_redirect(controller.base_url() + '/login')

        class Stats():
            total = 0
            unclassified = 0
            unlinked = 0

        if q:
            db_packages = Package.query.filter_by(package=q).order_by(\
             asc(Package.version), asc(Package.package)).all()
        else:
            db_packages = Package.query.order_by( \
             asc(Package.version), asc(Package.package)).all()
        packages = {}
        last_package_version = None
        stats = Stats()

        # Walk the packages list, skip classified and linked
        for package in db_packages:
            package_version = package.package + "-" + package.version
            source_package = package.source or package.package
            if package_version == last_package_version:
                continue
            if len(package.lists) == 0:  # package is not in a repos
                continue
            last_package_version = package_version
            stats.total += 1
            app = None
            if package.install_class == None:
                stats.unclassified += 1
            elif package.install_class == 'M':
                app = Application.query.filter_by(
                    source_package=source_package).first()
                if not app:
                    stats.unlinked += 1
            if q or not package.install_class or \
             (package.install_class=='M' and not app):
                if not source_package in packages.keys():
                    packages[source_package] = []
                packages[source_package].append(package)
        ordered_packages = OrderedDict(
            sorted(packages.items(), key=lambda t: t[0]))
        return template.render("packages.html",
                               packages=ordered_packages,
                               stats=stats,
                               q=q)
Example #16
0
	def index(self, q=None):
		"""
		The is the main page which presents the list of packages
		if no key (q) is specified only the packages needing an action
		are shown.
		"""
		if not userinfo.is_admin():
			controller.http_redirect(controller.base_url()+'/login')

		class Stats():
			total = 0
			unclassified = 0
			unlinked = 0

		if q:
			db_packages = Package.query.filter_by(package=q).order_by(\
				asc(Package.version), asc(Package.package)).all()
		else:
			db_packages = Package.query.order_by( \
				asc(Package.version), asc(Package.package)).all()
		packages = {}
		last_package_version = None
		stats = Stats()

		# Walk the packages list, skip classified and linked
		for package in db_packages:
			package_version = package.package+"-"+package.version
			source_package = package.source or package.package
			if package_version == last_package_version:
				continue
			if len(package.lists) == 0: # package is not in a repos
				continue
			last_package_version = package_version
			stats.total += 1
			app = None
			if package.install_class == None:
				stats.unclassified += 1
			elif package.install_class == 'M':
				app = Application.query.filter_by(
					source_package = source_package
				).first()
				if not app:
					stats.unlinked += 1
			if q or not package.install_class or \
				(package.install_class=='M' and not app):
					if not source_package in packages.keys():
						packages[source_package] = []
					packages[source_package].append(package)
		ordered_packages=OrderedDict(sorted(packages.items(), key=lambda t: t[0]))
		return template.render("packages.html", packages = ordered_packages
			, stats = stats, q=q
		)
Example #17
0
 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)
Example #18
0
	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
			)
Example #19
0
 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)
Example #20
0
	def index(self):
		(sponsor, sponsor_total) = sponsors.get_sponsor()
		return template.render("welcome.html", sponsor = sponsor
							   , sponsor_total = sponsor_total)
Example #21
0
 def index(self):
     return template.render("about.html")
Example #22
0
 def index(self):
     return template.render(self.view)
Example #23
0
 def index(self):
     (sponsor, sponsor_total) = sponsors.get_sponsor()
     return template.render("welcome.html",
                            sponsor=sponsor,
                            sponsor_total=sponsor_total)
Example #24
0
def error_page_404(status, message, traceback, version):
    return template.render("404.html")
Example #25
0
def updates_page(distro, release, **kwargs):
    """ Builds the updates page """

    try:
        page = int(kwargs.get("page", 1))
    except ValueError:
        page = 1
    updates_release = release
    q = kwargs.get("q", None)
    category_name = kwargs.get("category", None)
    format = kwargs.get("format", None)
    category = None
    categories = ApplicationsCategory.query.all()
    if category_name:
        category = ApplicationsCategory.query.filter_by(
            name=category_name).first()
        if not category:
            controller.http_redirect(controller.base_url()+"/updates/Ubuntu/" + \
                controller.current_release)
    codename = distroinfo.get_codename(distro, release)
    if format == "xml":
        items_per_page = 100
    else:
        items_per_page = 5
    (applications_list, package_dict, page_count) = \
        packages.get_applications_list(q = q, category = category, page = page
                                        , release = release , items_per_page = items_per_page
                                        )

    # Determine the "Available for" releases
    available_for = {}
    for app in applications_list:
        package = Package.query.filter_by( id = package_dict[app.id].id)\
             .order_by(desc(Package.last_modified)).first()
        available_for[app.id] = {}
        available_for[app.id] = []
        for packagelist in package.lists:
            if packagelist.version not in available_for[app.id]:
                available_for[app.id].append(packagelist.version)

    # Build the changelogs urls
    changelogs_dict = {}
    for app in applications_list:
        package = Package.query.filter_by( id = package_dict[app.id].id)\
             .order_by(desc(Package.last_modified)).first()
        source_package = package.source or package.package
        if source_package[:3] == 'lib':
            prefix = source_package[:4]
        else:
            prefix = source_package[:1]

        changelogs_dict[app.id] = '%s/%s/%s_%s_source.changelog' % \
            (prefix, source_package, source_package, package.version)

    # get the download stats
    download_stats = packages.get_download_stats()

    search_str = controller.self_url() + "?"
    param_str = ''
    for key, value in kwargs.iteritems():
        if key == "page":
            continue
        param_str += key + '=' + value + '&amp;'
    if param_str:
        search_str = controller.self_url() + '?' + param_str
    if format == "xml":
        return template.render('updates.xml',
                               applications_list=applications_list,
                               package_dict=package_dict,
                               available_for=available_for,
                               updates_release=updates_release,
                               changelogs_dict=changelogs_dict)
    else:
        return template.render('updates.html',
                               categories=categories,
                               applications_list=applications_list,
                               package_dict=package_dict,
                               available_for=available_for,
                               page=page,
                               page_count=page_count,
                               q=q,
                               category=category,
                               search_str=search_str,
                               updates_release=updates_release,
                               codename=codename,
                               changelogs_dict=changelogs_dict,
                               download_stats=download_stats)
Example #26
0
def updates_page(distro, release, **kwargs):
    """ Builds the updates page """
    
    try:
        page = int(kwargs.get("page", 1))
    except ValueError:
        page = 1
    updates_release = release                        
    q = kwargs.get("q", None)    
    category_name = kwargs.get("category", None)
    format = kwargs.get("format", None)
    category = None    
    categories = ApplicationsCategory.query.all() 
    if category_name:
        category = ApplicationsCategory.query.filter_by(name=category_name).first()
        if not category:
            controller.http_redirect(controller.base_url()+"/updates/Ubuntu/" + \
                controller.current_release)
    codename = distroinfo.get_codename(distro, release) 
    if format == "xml":
        items_per_page = 100
    else:
        items_per_page = 5
    (applications_list, package_dict, page_count) = \
        packages.get_applications_list(q = q, category = category, page = page 
                                        , release = release , items_per_page = items_per_page
                                        )
                        
    # Determine the "Available for" releases 
    available_for = {}
    for app in applications_list:        
        package = Package.query.filter_by( id = package_dict[app.id].id)\
             .order_by(desc(Package.last_modified)).first()
        available_for[app.id] = {}
        available_for[app.id] = []
        for packagelist in package.lists:
            if packagelist.version not in available_for[app.id]:
                available_for[app.id].append(packagelist.version)  
    
    # Build the changelogs urls
    changelogs_dict ={}
    for app in applications_list:        
        package = Package.query.filter_by( id = package_dict[app.id].id)\
             .order_by(desc(Package.last_modified)).first()
        source_package = package.source or package.package             
        if source_package[:3] == 'lib':
            prefix = source_package[:4]
        else:
            prefix = source_package[:1]
        
        changelogs_dict[app.id] = '%s/%s/%s_%s_source.changelog' % \
            (prefix, source_package, source_package, package.version)

    # get the download stats
    download_stats = packages.get_download_stats()

    search_str = controller.self_url()+"?"
    param_str = ''
    for key,value in kwargs.iteritems():
        if key == "page": 
            continue        
        param_str += key + '=' + value + '&amp;'
    if param_str:
        search_str = controller.self_url()+ '?' + param_str
    if format == "xml":
        return template.render('updates.xml' 
            , applications_list = applications_list
            , package_dict = package_dict 
            , available_for = available_for    
            , updates_release = updates_release 
            , changelogs_dict = changelogs_dict                    
        )
    else: 
        return template.render('updates.html'
            , categories = categories 
            , applications_list = applications_list 
            , package_dict = package_dict 
            , available_for = available_for 
            , page = page 
            , page_count = page_count 
            , q = q 
            , category = category 
            , search_str = search_str
            , updates_release = updates_release
            , codename = codename
            , changelogs_dict = changelogs_dict
            , download_stats=download_stats
    )
Example #27
0
def error_page_404(status, message, traceback, version):
	return template.render("404.html")
Example #28
0
 def index(self):
     return template.render(self.view)