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


Python Status.save方法代码示例

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


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

示例1: index

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
def index(request):
    all_messages = Status.objects.all()

    if request.method == "POST":
        msg_id = request.POST.get("msg_id", None)
        del_msg = request.POST.get("del_msg", None)
        new_msg = request.POST.get("new_msg", None)
        if (msg_id is not None) and (del_msg is not None):
            try:
                this_status = Status.objects.get(pk=msg_id)
                this_status.delete()
                success_msg = "Deleted message: {}".format(this_status.msg)
                messages.add_message(request, messages.SUCCESS, success_msg)
            except:
                error_msg = "Something went wrong while deleting message {}".format(msg_id)
                messages.add_message(request, messages.ERROR, error_msg)
        if new_msg is not None:
            try:
                new_status = Status()
                new_status.msg = new_msg
                new_status.save()
                success_msg = "Created new message: {}".format(new_msg)
                messages.add_message(request, messages.SUCCESS, success_msg)
            except:
                error_msg = "Something went wrong while creating: {}".format(new_msg)
                messages.add_message(request, messages.ERROR, error_msg)
    all_msgs = Status.objects.all()
    return render_to_response("status_board.html", {"all_msgs": all_msgs}, context_instance=RequestContext(request))
开发者ID:brousch,项目名称:whoisthere,代码行数:30,代码来源:views.py

示例2: sms

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
def sms():
    if request.method == 'POST':
        print >> sys.stderr, "Received POST request to /plivo/sms/" # this is how you write messages to yourself in the Apache /var/log/apache2/error.log
        try:
            s = SMS(timeAnswered = datetime.datetime.now(),
                                action = 'super text',
                                direction = 'incoming',
                                smsTo = request.form['To'],
                                smsType = request.form['Type'],
                                smsMessageUUID = request.form['MessageUUID'],
                                smsFrom = request.form['From'],
                                smsText = request.form['Text'],
                                )
            print >> sys.stderr, s.direction
            s.save()
            message = request.form['Text'].lower()
            #response = showtimeandloc(message)
            #Dispatcher for the various commands
            try:
                response = commands[message[0]](message)
            except:
                response = "This was not a valid command.  Try @,!,g, or h.  H for help."

            print >> sys.stderr, response
            caller = request.form['From']
            if User.query.filter(User.number == caller).first():
                if type(response) == type(dict()):
                    regisUser = User.query.filter(User.number == caller).first()
                    location = response['location']
                    print >> sys.stderr, location
                    hours = int(response['hours'])
                    print >> sys.stderr, hours
                    timeExpired = datetime.datetime.now() + datetime.timedelta(hours=hours)
                    print >> sys.stderr, timeExpired
                    condition = 'safe'
                    newStatus = Status(location=location,timeEntered=datetime.datetime.now(),timeExpired=timeExpired,condition=condition)
                    newStatus.save()
                    regisUser.status = newStatus
                    regisUser.save()
                    yourStatus = 'We know you are at ' + location + ' for ' + str(hours) + ' hours. Now we are watching you.'
                    send_txt(caller,yourStatus.upper())
                elif type(response) == type(str()):
                    send_txt(caller,response.upper(), src=MASTER_NUMBER)
                else:
                    oops = 'Sorry. Please make sure you enter your status in this format: @ location 4 numberofhours.'
                    send_txt(caller,oops.upper())
            else:
                response = "Welcome to Panoptincon, where we aren't always watching. Your default location is Speke Apartments."
                timeExpired = datetime.datetime.now() + datetime.timedelta(hours=24)
                newStatus = Status(location='Speke Apartments',timeEntered=datetime.datetime.now(),timeExpired=timeExpired,condition='safe')
                newStatus.save()
                newUser = User(number=caller, status=newStatus, createdAt=datetime.datetime.now(), name=message, isChin=False)
                newUser.save()
                send_txt(caller,response.upper(), src=MASTER_NUMBER)
        except:
            print >> sys.stderr, str(sys.exc_info()[0])
            print >> sys.stderr, str(sys.exc_info()[1])
            #entering the gateway where stuff happens!
    else:
        return "These aren't the droids you're looking for. Move along, move along."
开发者ID:elizabethmgin,项目名称:panoptincon,代码行数:62,代码来源:views.py

示例3: get_status

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
def get_status(request=None):
    status = Status.objects.all()
    if status:
        return status[0]
    else:
        status = Status(step=1, running_status='normal')
        status.save()
    return status
开发者ID:volturius,项目名称:EasierLinux,代码行数:10,代码来源:views.py

示例4: status_add

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
def status_add(request):
         data = JSONParser().parse(request)
         status_object=Status(content=data["content"],owner=request.user.profile)
         status_object.save()
         serializer=StatusSerializer(status_object)
         if serializer:
            return JSONResponse(serializer.data, status=201)
         return JSONResponse(serializer.errors, status=400)
开发者ID:RyadElssalihine,项目名称:RyadElssalihine,代码行数:10,代码来源:views.py

示例5: home

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
def home(request):
	# form = StatusForm()
	if request.method == "POST":
		status = Status()
		status.status_text = request.POST['status_text']
		status.save()
		print request
	status = Status.objects.all()
	return render(request, 'statusBox/home.html', {'status': status})
开发者ID:hfalk,项目名称:fagkom.no,代码行数:11,代码来源:views.py

示例6: post

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
	def post(self, request, format=None):

		user_id = request.DATA['user_id']
		date = request.DATA['date']
		temp = request.DATA['temp']

		user = User.objects.get(user_id=user_id)
		user_status = Status(temp = temp, date = date, user = user)
		user_status.save()

		return HttpResponse(content=user_status, status=status.HTTP_201_CREATED)
开发者ID:victorcarrico,项目名称:thermo,代码行数:13,代码来源:views.py

示例7: test_status_create

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
 def test_status_create(self):
     s = Status(co_num = 14456,
                description = 'Sample Status',
                role = 'Developer')
     s.save()
     t = Task(user = "adam",
              date = date.today(),
              status = s,
              total_minutes = 13)
     t.save()
     status = str(s)
     task = str(t)
开发者ID:McPolemic,项目名称:BTMS,代码行数:14,代码来源:tests.py

示例8: set_status

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
def set_status(request=None, step=0, running_status=''):
    status = Status.objects.all()
    if status:
        status = status[0]
        if step:
            status.step = step
        if running_status:
            status.running_status = running_status
        status.save()
    else:
        status = Status(step=step, running_status=running_status)
        status.save()
    return HttpResponseRedirect('/')
开发者ID:volturius,项目名称:EasierLinux,代码行数:15,代码来源:views.py

示例9: setUp

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
 def setUp(self):
     s = Status(co_num = 14456,
                description = 'Sample Status',
                role = 'Developer')
     s.save()
     t = Task(user = "adam",
              date = date(2012, 3, 18),
              status = s,
              total_minutes = 90)
     t.save()
     t2 = Task(user = "adam",
               date = date(2012, 3, 19),
               status = s,
               total_minutes = 120)
     t2.save()
开发者ID:McPolemic,项目名称:BTMS,代码行数:17,代码来源:tests.py

示例10: store_single_status

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
def store_single_status(status_dict, rewteet):
    """
    json status dict -> database
    returns Status
    """
    try:
        s = Status.objects.get(id = status_dict.id)
    except Status.DoesNotExist:
        s = Status()
        s.id = status_dict.id
        s.set_content(status_dict)
        s.retweet = rewteet
        s.save()
        
    return s
开发者ID:xurubin,项目名称:WeiboObservatory,代码行数:17,代码来源:crawl.py

示例11: save_status

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
def save_status(request):
	id = request.POST['id']
	report = Report.objects.get(id=id)
	message = request.POST['message']
	note = request.POST['note']
	user = request.user
	new_status = Status()
	new_status.tech = user
	new_status.report = report
	new_status.message = message
	new_status.note = note
	new_status.save()

	if message == 'p':
		report.completed = True
		report.save()

	return HttpResponseRedirect('/reports/' + id)
开发者ID:BobNisco,项目名称:fall-2012-hackathon,代码行数:20,代码来源:views.py

示例12: post

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
	def post(request, status_id):
		form = forms.StatusForm(request.POST)
		if form.is_valid():
			data = form.cleaned_data
			if status_id:
				status = utils.get_object_by_id(Status, status_id)
				status.body_text = data['body_text']
				status.title = data['title']
				status.save()
			else:
				status = Status(author    = request.user,
												title     = data['title'],
												body_text = data['body_text']
										)
				status.save()
				send_notification_to_admin('status', status = status, category = 'POSTED')
		else:
			raise exceptions.DataFieldMissed
				
		return {'object': status}
开发者ID:hfercc,项目名称:wboard,代码行数:22,代码来源:views.py

示例13: cpanel_submit

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import save [as 别名]
def cpanel_submit(request):
	# The user adding the request
	user = request.user

	name = request.POST['name']
	phone = request.POST['phone']
	email = request.POST['email']
	type = request.POST['device']
	os = request.POST['os']
	problem = request.POST['problem']
	description = request.POST['description']
	deviceObj = Device()
	report = Report()
	usersWithSameEmail = User.objects.filter(email=email)
	reportUser = User()

	userFound = False
	for u in usersWithSameEmail:
		# If user exists, don't create a new one
		if u.email == email:
			reportUser = u
			userFound = True

	if not userFound:
		reportUser.email = email
		reportUser.username = name
		reportUser.password = 'password'
		reportUser.save()

	# Get the devices the user has
	usersDevices = Device.objects.filter(owner=reportUser)

	deviceFound = False
	for d in usersDevices:
		# If the device exists recognize it, and use it
		if d.os == os and d.type == type:
			deviceObj = d
			deviceFound = True

	if not deviceFound:
		# Generate device object
		deviceObj.owner = reportUser
		deviceObj.os = os
		deviceObj.type = type
		deviceObj.save()

	# Generate Report
	report.owner = reportUser
	report.device = deviceObj
	report.description = description
	report.problem = problem
	report.completed = False
	report.save()

	# Generate initial status
	status = Status()
	status.report = report
	# Checked in message
	status.message = 'c'
	status.tech = user
	status.save()

	return cpanel(request, True)
开发者ID:BobNisco,项目名称:fall-2012-hackathon,代码行数:65,代码来源:views.py


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