本文整理汇总了Python中rainwave.user.User.has_perks方法的典型用法代码示例。如果您正苦于以下问题:Python User.has_perks方法的具体用法?Python User.has_perks怎么用?Python User.has_perks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rainwave.user.User
的用法示例。
在下文中一共展示了User.has_perks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RainwaveHandler
# 需要导入模块: from rainwave.user import User [as 别名]
# 或者: from rainwave.user.User import has_perks [as 别名]
#.........这里部分代码省略.........
self.cleaned_args[field] = parsed
if self.sid is None and not self.sid_required:
self.sid = config.get("default_station")
if self.sid == 0 and self.allow_sid_zero:
pass
elif not self.sid in config.station_ids:
raise APIException("invalid_station_id", http_code=400)
if self.sid:
self.set_cookie("r4_sid", str(self.sid), expires_days=365, domain=config.get("cookie_domain"))
if self.phpbb_auth:
self.do_phpbb_auth()
else:
self.rainwave_auth()
if not self.user and self.auth_required:
raise APIException("auth_required", http_code=403)
elif not self.user and not self.auth_required:
self.user = User(1)
self.user.ip_address = self.request.remote_ip
self.user.refresh(self.sid)
if self.user and config.get("store_prefs"):
self.user.save_preferences(self.request.remote_ip, self.get_cookie("r4_prefs", None))
if self.login_required and (not self.user or self.user.is_anonymous()):
raise APIException("login_required", http_code=403)
if self.tunein_required and (not self.user or not self.user.is_tunedin()):
raise APIException("tunein_required", http_code=403)
if self.admin_required and (not self.user or not self.user.is_admin()):
raise APIException("admin_required", http_code=403)
if self.perks_required and (not self.user or not self.user.has_perks()):
raise APIException("perks_required", http_code=403)
if self.unlocked_listener_only and not self.user:
raise APIException("auth_required", http_code=403)
elif self.unlocked_listener_only and self.user.data['lock'] and self.user.data['lock_sid'] != self.sid:
raise APIException("unlocked_only", station=config.station_id_friendly[self.user.data['lock_sid']], lock_counter=self.user.data['lock_counter'], http_code=403)
is_dj = False
if self.dj_required and not self.user:
raise APIException("dj_required", http_code=403)
if self.dj_required and not self.user.is_admin():
#pylint: disable=E1103
potential_dj_ids = []
if cache.get_station(self.sid, "sched_current") and cache.get_station(self.sid, "sched_current").dj_user_id:
potential_dj_ids.append(cache.get_station(self.sid, "sched_current").dj_user_id)
if cache.get_station(self.sid, "sched_next"):
for evt in cache.get_station(self.sid, "sched_next"):
potential_dj_ids.append(evt.dj_user_id)
if cache.get_station(self.sid, "sched_history") and cache.get_station(self.sid, "sched_history")[-1].dj_user_id:
potential_dj_ids.append(cache.get_station(self.sid, "sched_history")[-1].dj_user_id)
if not self.user.id in potential_dj_ids:
raise APIException("dj_required", http_code=403)
is_dj = True
#pylint: enable=E1103
if self.dj_preparation and not is_dj and not self.user.is_admin():
if not db.c.fetch_var("SELECT COUNT(*) FROM r4_schedule WHERE sched_used = 0 AND sched_dj_user_id = %s", (self.user.id,)):
raise APIException("dj_required", http_code=403)
def do_phpbb_auth(self):
phpbb_cookie_name = config.get("phpbb_cookie_name")
user_id = fieldtypes.integer(self.get_cookie(phpbb_cookie_name + "u", ""))