当前位置: 首页>>代码示例>>Python>>正文


Python User.is_admin方法代码示例

本文整理汇总了Python中rainwave.user.User.is_admin方法的典型用法代码示例。如果您正苦于以下问题:Python User.is_admin方法的具体用法?Python User.is_admin怎么用?Python User.is_admin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rainwave.user.User的用法示例。


在下文中一共展示了User.is_admin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: RainwaveHandler

# 需要导入模块: from rainwave.user import User [as 别名]
# 或者: from rainwave.user.User import is_admin [as 别名]

#.........这里部分代码省略.........
					raise APIException("invalid_argument", argument=field, reason="%s %s" % (field, getattr(fieldtypes, "%s_error" % type_cast.__name__)), http_code=400)
				else:
					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):
开发者ID:Siqo53,项目名称:rainwave,代码行数:70,代码来源:web.py


注:本文中的rainwave.user.User.is_admin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。