本文整理汇总了Python中models.Channel.save方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.save方法的具体用法?Python Channel.save怎么用?Python Channel.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Channel
的用法示例。
在下文中一共展示了Channel.save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import save [as 别名]
def index(request):
# Validate token from Slack.
token = request.GET['token']
if (token != 'RNmcnBKCdOZBfs3S7habfT85'):
return JsonResponse({'text': 'ERROR: Invalid token %s' % token})
# Fetch channel if it exists, else create a new Channel object.
channel_id = request.GET['channel_id']
try:
channel = Channel.objects.get(channel_id=channel_id)
except Channel.DoesNotExist:
channel = Channel(channel_id=channel_id)
channel.save()
# Parse command from user.
command = request.GET['text']
args = command.split(' ')
if (len(args) < 1 or args[0] == 'help'):
return showHelp()
elif (args[0] == 'startGame'):
return startGame(args, request.GET['user_name'], channel)
elif (args[0] == 'makeMove'):
return makeMove(args, request.GET['user_name'], channel)
elif (args[0] == 'showBoard'):
return showBoard(channel)
else:
return showHelp()
示例2: fetchDataset
# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import save [as 别名]
def fetchDataset (self):
"""Fetch a dataset to the list of cacheable datasets"""
token = self.dataset_name.split('-')[0]
try:
json_info = json.loads(getURL('http://{}/ocpca/{}/info/'.format(settings.SERVER, token)))
except Exception as e:
logger.error("Token {} doesn not exist on the backend {}".format(token, settings.SERVER))
raise NDTILECACHEError("Token {} doesn not exist on the backend {}".format(token, settings.SERVER))
ximagesize, yimagesize, zimagesize = json_info['dataset']['imagesize']['0']
xoffset, yoffset, zoffset = json_info['dataset']['offset']['0']
xvoxelres, yvoxelres, zvoxelres = json_info['dataset']['voxelres']['0']
scalinglevels = json_info['dataset']['scalinglevels']
scalingoption = ND_scalingtoint[json_info['dataset']['scaling']]
starttime, endtime = json_info['dataset']['timerange']
project_name = json_info['project']['name']
s3backend = json_info['project']['s3backend']
self.ds = Dataset(dataset_name=self.dataset_name, ximagesize=ximagesize, yimagesize=yimagesize, zimagesize=zimagesize, xoffset=xoffset, yoffset=yoffset, zoffset=zoffset, xvoxelres=xvoxelres, yvoxelres=yvoxelres, zvoxelres=zvoxelres, scalingoption=scalingoption, scalinglevels=scalinglevels, starttime=starttime, endtime=endtime, project_name=project_name, s3backend=s3backend)
self.ds.save()
for channel_name in json_info['channels'].keys():
channel_name = channel_name
dataset_id = self.dataset_name
channel_type = json_info['channels'][channel_name]['channel_type']
channel_datatype = json_info['channels'][channel_name]['datatype']
startwindow, endwindow = json_info['channels'][channel_name]['windowrange']
propagate = json_info['channels'][channel_name]['propagate']
readonly = json_info['channels'][channel_name]['readonly']
ch = Channel(channel_name=channel_name, dataset=self.ds, channel_type=channel_type, channel_datatype=channel_datatype, startwindow=startwindow, endwindow=endwindow, propagate=propagate, readonly=readonly)
ch.save()
示例3: channel_add
# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import save [as 别名]
def channel_add():
j = request.get_json()
c = Channel(j)
c.save()
responseData = {
'channel_name': c.name,
'channel_id': c.id,
}
return json.dumps(responseData, indent=2)
示例4: channel_add
# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import save [as 别名]
def channel_add():
user = current_user()
is_admin = is_administrator(user)
log('Is admin? ', is_admin)
if is_admin:
j = request.json
c = Channel(j)
c.save()
responseData = {
'channel_name': c.name,
'channel_id': c.id,
}
return json.dumps(responseData, indent=2)
else:
abort(401)
示例5: newchan
# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import save [as 别名]
def newchan(request):
if request.method == 'POST':
uc = NewChanForm(request.POST)
if uc.is_valid():
cname = uc.cleaned_data['cname']
chan = Channel(name=cname, description=uc.cleaned_data['desc'], publish=[request.user.username,], subscribe=[request.user.username,], creator=request.user)
#request.user.publish.append(cname)
#request.user.subscribe.append(cname)
chan.save()
#request.user.save()
return render_to_response('chancreated.html', {'cname': cname}, context_instance=RequestContext(request))
else:
return render_to_response('chancreate.html', {'form': uc}, context_instance=RequestContext(request))
uc = NewChanForm()
return render_to_response('chancreate.html', {'form': uc}, context_instance=RequestContext(request))
示例6: channel_new
# 需要导入模块: from models import Channel [as 别名]
# 或者: from models.Channel import save [as 别名]
def channel_new():
c = Channel(request.form)
c.save()
# print('channel_new: ', c)
return render_template('new_channel.html')