def ignore_action(self, pn, ver): """Process ignore form""" timestamp = asctime(gmtime()) try: pkg = Packages.select( AND(Packages.q.packageName == pn, Packages.q.latestReleaseVersion == ver)) pkg[0].destroySelf() if self.verbose: print "Deleted match:", pn except: msg = "%s ERROR - Failed to ignore %s-%s" % (timestamp, pn, ver) utils.admin_log_msg(msg) yield self.error_form(msg) return ignore = Ignores(packageName=pn, latestReleaseVersion=ver) username = accounts.get_logged_username() msg = "%s %s IGNORE %s-%s" % (timestamp, username, pn, ver) utils.admin_log_msg(msg) template = Template( '''Freshmeat version $ver of $pn ignored. <br><br>Go <a href='/'>back</a>''', [locals(), globals()]) content = template.respond() yield self.plain_page(content)
def set_troves_session(): """Set session var with troves user is interested in""" username = accounts.get_logged_username() if username: user = Users.select(Users.q.user == username) troves = user[0].troves if troves: cherrypy.session['troves'] = troves else: cherrypy.session['troves'] = None else: cherrypy.session['troves'] = None
def set_herd_session(): """Set session var with herds user belongs to""" username = accounts.get_logged_username() if username: user = Users.select(Users.q.user == username) if user[0].herdsUser: herds = user[0].herdsAuto + " " + user[0].herdsUser herds = " ".join(herds.split()) else: herds = user[0].herdsAuto cherrypy.session['herds'] = herds else: cherrypy.session['herds'] = None
def process_user_herd(self, herd, *args, **kwargs): """Process add user herd request.""" username = accounts.get_logged_username() h = Users.select(Users.q.user == username) if h[0]: h[0].set(herdsUser = h[0].herdsUser + " " + herd) else: h[0].set(herdsUser = herd) utils.set_herd_session() content = "<b>Success!</b><br><br>Go <a href='/'>home</a>" yield self.plain_page(content)
def process_user_herd(self, herd, *args, **kwargs): """Process add user herd request.""" username = accounts.get_logged_username() h = Users.select(Users.q.user == username) if h[0]: h[0].set(herdsUser=h[0].herdsUser + " " + herd) else: h[0].set(herdsUser=herd) utils.set_herd_session() content = "<b>Success!</b><br><br>Go <a href='/'>home</a>" yield self.plain_page(content)
def process_user_trove(self, trove, *args, **kwargs): """Process add user trove request.""" username = accounts.get_logged_username() h = Users.select(Users.q.user == username) if h[0].troves: h[0].set(troves=h[0].troves + " " + trove) else: h[0].set(troves=trove) utils.set_troves_session() content = "<b>Success!</b><br><br>Go <a href='/'>home</a>" yield self.plain_page(content)
def process_user_trove(self, trove, *args, **kwargs): """Process add user trove request.""" username = accounts.get_logged_username() h = Users.select(Users.q.user == username) if h[0].troves: h[0].set(troves = h[0].troves + " " + trove) else: h[0].set(troves = trove) utils.set_troves_session() content = "<b>Success!</b><br><br>Go <a href='/'>home</a>" yield self.plain_page(content)
def index(self, verbose=None): """Main index.html page""" #verbose=1 will show you sql id's for debugging #For debugging, seeing cookies etc: if self.verbose: #print cherrypy.request.headerMap #print "VERBOSE", cherrypy.request.remote.ip pass week = utils.get_days() #FIXME: Show either pkgs needing bump or all fm pkgs packages = Packages.select( AND( OR(Packages.q.latestReleaseDate == week[0], Packages.q.latestReleaseDate == week[1], Packages.q.latestReleaseDate == week[2], Packages.q.latestReleaseDate == week[3], Packages.q.latestReleaseDate == week[4]), Packages.q.fmNewer == 1)) #packages = Packages.select(OR(Packages.q.latestReleaseDate == week[0], # Packages.q.latestReleaseDate == week[1], # Packages.q.latestReleaseDate == week[2], # Packages.q.latestReleaseDate == week[3], # Packages.q.latestReleaseDate == week[4] # )) packages = packages.orderBy('latestReleaseDate').reversed() try: my_herds = cherrypy.session['herds'].split(" ") except: my_herds = None try: troves = cherrypy.session['troves'].split(" ") except: troves = None tr = {} if troves: for t in troves: a = Troves.select(Troves.q.fId == t) tr[t] = a[0].name self._body_tmpl.troves = tr self._body_tmpl.username = accounts.get_logged_username() self._body_tmpl.week = week self._body_tmpl.my_herds = my_herds self._body_tmpl.packages = packages self._body_tmpl.verbose = verbose return header() + self._body_tmpl.respond() + footer()
def index(self, verbose = None): """Main index.html page""" #verbose=1 will show you sql id's for debugging #For debugging, seeing cookies etc: if self.verbose: #print cherrypy.request.headerMap #print "VERBOSE", cherrypy.request.remote.ip pass week = utils.get_days() #FIXME: Show either pkgs needing bump or all fm pkgs packages = Packages.select(AND(OR(Packages.q.latestReleaseDate == week[0], Packages.q.latestReleaseDate == week[1], Packages.q.latestReleaseDate == week[2], Packages.q.latestReleaseDate == week[3], Packages.q.latestReleaseDate == week[4] ), Packages.q.fmNewer==1)) #packages = Packages.select(OR(Packages.q.latestReleaseDate == week[0], # Packages.q.latestReleaseDate == week[1], # Packages.q.latestReleaseDate == week[2], # Packages.q.latestReleaseDate == week[3], # Packages.q.latestReleaseDate == week[4] # )) packages = packages.orderBy('latestReleaseDate').reversed() try: my_herds = cherrypy.session['herds'].split(" ") except: my_herds = None try: troves = cherrypy.session['troves'].split(" ") except: troves = None tr = {} if troves: for t in troves: a = Troves.select(Troves.q.fId == t) tr[t] = a[0].name self._body_tmpl.troves = tr self._body_tmpl.username = accounts.get_logged_username() self._body_tmpl.week = week self._body_tmpl.my_herds = my_herds self._body_tmpl.packages = packages self._body_tmpl.verbose = verbose return header() + self._body_tmpl.respond() + footer()
def change_passwd_action(self, old_passwd, new_passwd, confirm_passwd, *args, **kwargs): username = accounts.get_logged_username() password = accounts.get_user_passwd(username) if password != old_passwd: yield self.error_form('''Old password is incorrect.<br><br> <a href='/change_passwd'> Try again.</a>''') return if new_passwd != confirm_passwd: yield self.error_form('''New passwords don't match.<br><br> <a href='/change_passwd'> Try again.</a>''') return if accounts.change_passwd(username, new_passwd): yield self.plain_page("<b>Password changed.</b>") else: yield self.error_form("Error: Failed to change passwd.")
def del_user_trove(self, trove): """Delete user's trove""" username = accounts.get_logged_username() u = Users.select(Users.q.user == username) if trove in u[0].troves: s = u[0].troves.split() s.remove(trove) if s: u[0].set(troves=" ".join(s)) else: u[0].set(troves="") else: #weird yield self.error_form("Couldn't find that trove in your list.") return utils.set_troves_session() content = "<b>Success!</b><br><br>Go <a href='/'>home</a>" yield self.plain_page(content)
def del_user_trove(self, trove): """Delete user's trove""" username = accounts.get_logged_username() u = Users.select(Users.q.user == username) if trove in u[0].troves: s = u[0].troves.split() s.remove(trove) if s: u[0].set(troves = " ".join(s)) else: u[0].set(troves = "") else: #weird yield self.error_form ("Couldn't find that trove in your list.") return utils.set_troves_session() content = "<b>Success!</b><br><br>Go <a href='/'>home</a>" yield self.plain_page(content)
def known_submit(self, new_cat="", new_pn="", fmpn=""): """Add submitted known match to db""" username = accounts.get_logged_username() timestamp = asctime(gmtime()) msg = "%s %s CHANGE " % (timestamp, username) if not new_pn or not new_cat: yield self.error_form("No package specified!") return good = KnownGood.select(KnownGood.q.fmName == fmpn ) if good.count(): # found existing good try: good[0].set(packageName = new_pn, portageCategory = new_cat) msg += "%s-%s NEW_PN NEW_CAT\n" % (new_pn, new_cat) except: yield self.error_form("Failed to update database!") return else: # add new known-good try: g=KnownGood(packageName = new_pn, portageCategory = new_cat, fmName = fmpn) msg += "%s-%s %s NEW_PN NEW_CAT FMNM\n" % (new_pn, new_cat, fmpn) except: yield self.error_form("Failed to update database!") return packages = Packages.select(Packages.q.fmName == fmpn ) try: packages[0].set(packageName = new_pn, portageCategory = new_cat) msg += "%s-%s NEW_PN NEW_CAT\n" % (new_pn, new_cat) except: yield self.error_form("Failed to update database!") return utils.admin_log_msg(msg) content = "<b>Success!</b><br><br>Go <a href='/'>home</a>" yield self.plain_page(content)
def known_submit(self, new_cat="", new_pn="", fmpn=""): """Add submitted known match to db""" username = accounts.get_logged_username() timestamp = asctime(gmtime()) msg = "%s %s CHANGE " % (timestamp, username) if not new_pn or not new_cat: yield self.error_form("No package specified!") return good = KnownGood.select(KnownGood.q.fmName == fmpn) if good.count(): # found existing good try: good[0].set(packageName=new_pn, portageCategory=new_cat) msg += "%s-%s NEW_PN NEW_CAT\n" % (new_pn, new_cat) except: yield self.error_form("Failed to update database!") return else: # add new known-good try: g = KnownGood(packageName=new_pn, portageCategory=new_cat, fmName=fmpn) msg += "%s-%s %s NEW_PN NEW_CAT FMNM\n" % (new_pn, new_cat, fmpn) except: yield self.error_form("Failed to update database!") return packages = Packages.select(Packages.q.fmName == fmpn) try: packages[0].set(packageName=new_pn, portageCategory=new_cat) msg += "%s-%s NEW_PN NEW_CAT\n" % (new_pn, new_cat) except: yield self.error_form("Failed to update database!") return utils.admin_log_msg(msg) content = "<b>Success!</b><br><br>Go <a href='/'>home</a>" yield self.plain_page(content)
def ignore_action(self, pn, ver): """Process ignore form""" timestamp = asctime(gmtime()) try: pkg = Packages.select(AND(Packages.q.packageName == pn, Packages.q.latestReleaseVersion == ver)) pkg[0].destroySelf() if self.verbose: print "Deleted match:", pn except: msg = "%s ERROR - Failed to ignore %s-%s" % (timestamp, pn, ver) utils.admin_log_msg(msg) yield self.error_form(msg) return ignore = Ignores(packageName = pn, latestReleaseVersion = ver) username = accounts.get_logged_username() msg = "%s %s IGNORE %s-%s" % (timestamp, username, pn, ver) utils.admin_log_msg(msg) template = Template('''Freshmeat version $ver of $pn ignored. <br><br>Go <a href='/'>back</a>''', [locals(), globals()]) content = template.respond() yield self.plain_page(content)
def del_user_herd(self, herd): """Delete user's herd""" username = accounts.get_logged_username() u = Users.select(Users.q.user == username) if herd in u[0].herdsAuto: yield self.error_form('''You are a member of that herd, which means you cannot delete it from your Meatoo preferences. Sorry.''') return elif herd in u[0].herdsUser: s = u[0].herdsUser.split() s.remove(herd) if s: u[0].set(herdsUser="******".join(s)) else: u[0].set(herdsUser="") else: #weird yield self.error_form("Couldn't find that herd in your list.") return utils.set_herd_session() content = "<b>Success!</b><br><br>Go <a href='/'>home</a>" yield self.plain_page(content)
def del_user_herd(self, herd): """Delete user's herd""" username = accounts.get_logged_username() u = Users.select(Users.q.user == username) if herd in u[0].herdsAuto: yield self.error_form('''You are a member of that herd, which means you cannot delete it from your Meatoo preferences. Sorry.''') return elif herd in u[0].herdsUser: s = u[0].herdsUser.split() s.remove(herd) if s: u[0].set(herdsUser = "******".join(s)) else: u[0].set(herdsUser = "") else: #weird yield self.error_form("Couldn't find that herd in your list.") return utils.set_herd_session() content = "<b>Success!</b><br><br>Go <a href='/'>home</a>" yield self.plain_page(content)