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


Python models.Status类代码示例

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


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

示例1: test_status_normal

    def test_status_normal(self):
        s = Status(name=u"Hey", slug=u"hey", description=u"runaway",
                   image=u"helloworld.png", severity=10)
        s.put()

        data = s.rest("/api")
        self.assertEquals(data["level"], "NORMAL")
开发者ID:2do,项目名称:stashboard,代码行数:7,代码来源:test_status.py

示例2: test_relationship

    def test_relationship(self):
        """Test relationships between users, devices, and statuses"""

        u = User('user1', 'user1_guid', 'Jon Doe', 'Jon', 'Doe', 'Department',
                '[email protected]')
        d = Device('device1', 'aa:bb:cc:dd:ee')
        s = Status('status-provider', 'in', dt.now())

        self.session.add(s)
        self.session.add(u)
        self.session.add(d)

        d.user = u
        s.user = u

        self.session.commit()

        pprint(u)
        pprint(d)
        pprint(s)

        pprint(u.devices)
        pprint(u.statuses)

        assert d.user == u
        assert d in u.devices

        assert s.user == u
        assert s in u.statuses

        assert u.devices[0] == d
        assert u.statuses[0] == s
开发者ID:beaugunderson,项目名称:people-poker,代码行数:32,代码来源:tests.py

示例3: index

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,代码行数:28,代码来源:views.py

示例4: data

    def data(self):
        services = []
        dstatus = Status.default()

        for s in Service.all().order("name").fetch(100):
            event = s.current_event()
            if event is not None:
                status = event.status
            else:
                status = dstatus

            service = {
                "slug": s.slug,
                "name": s.name,
                "url": s.url(),
                "status": status,
                "history": s.history(5, dstatus)
                }
            services.append(service)

        return {
            "days": get_past_days(5),
            "statuses": Status.all().fetch(100),
            "services": services,
            }
开发者ID:kyleconroy,项目名称:stashboard,代码行数:25,代码来源:site.py

示例5: post

    def post(self, version):
        
        if (self.valid_version(version)):
            name = self.request.get('name', default_value=None)
            description = self.request.get('description', default_value=None)
            image = self.request.get('image', default_value=None)
            level = self.request.get('level', default_value=None)
            severity = Level.get_severity(level)

            if name and description and severity and image:
                slug = slugify.slugify(name)
                status = Status.get_by_slug(slug)

                # Update existing resource
                if status:
                    status.description = description
                    status.severity = severity
                    status.image = image
                    status.name = name
                    status.put()
                    self.json(status.rest(self.base_url(version)))
                # Create new service
                else:
                    status = Status(name=name, slug=slug, description=description, 
                        severity=severity, image=image)
                    status.put()
                    self.json(status.rest(self.base_url(version)))
            else:
                self.error(400, "Bad Data")
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:samn,项目名称:stashboard,代码行数:31,代码来源:api.py

示例6: post

 def post(self):
     if not setup_occurred():
         Status.load_defaults()
         Image.load_defaults()
         api.invalidate_cache()
         finish_setup()
     self.redirect("/admin")
开发者ID:Homefinder,项目名称:stashboard,代码行数:7,代码来源:admin.py

示例7: data

    def data(self):
        services = []
        default_status = Status.get_default()

        query = Service.all().filter("list =", self.list).order("name")

        for service in query.fetch(100):
            event = service.current_event()
            if event is not None:
                status = event.status
            else:
                status = default_status

            today = date.today() + timedelta(days=1)
            current, = service.history(1, default_status, start=today)
            has_issues = (current["information"] and
                          status.key() == default_status.key())

            service_dict = {
                "slug": service.slug,
                "name": service.name,
                "url": service.url(),
                "status": status,
                "has_issues": has_issues,
                "history": service.history(5, default_status),
                }
            services.append(service_dict)

        return {
            "days": get_past_days(5),
            "statuses": Status.all().fetch(100),
            "services": services,
            }
开发者ID:Open-Source-GIS,项目名称:stashboard,代码行数:33,代码来源:site.py

示例8: get

    def get(self):
        user = users.get_current_user()
        total = TotalAmount.all().filter('user = ', user).get()

        if user and total:
            page = int(self.request.get('page', 1))

            if page > 0:
                offset = limit * (page - 1)
            else:
                self.redirect('/')
                return

            chart_labels, chart_values = mk_chart_data(total)
            total_status = Status.all().filter('user = ', user).count(1000)
            statuses = Status.all().filter('user = ', user).order('-updated_at').fetch(limit, offset)

            if len(statuses):
                self.render_response('index.html', {
                    'statuses': statuses,
                    'total_amount': total.amount,
                    'chart_labels': chart_labels,
                    'chart_values': chart_values,
                    'is_paginated': limit < total_status,
                    'has_previous': page > 1,
                    'has_next': (offset + limit) < total_status,
                    'previous_page': page - 1,
                    'next_page': page + 1,
                })
            else:
                self.render_response('index.html', {
                    'statuses': [],
                })
        else:
            self.render_response('index.html', {})
开发者ID:takatoshiono,项目名称:ibeer,代码行数:35,代码来源:index.py

示例9: test_status_warning

    def test_status_warning(self):
        s = Status(name=u"Hey", slug=u"hey", description=u"runaway",
                   image=u"helloworld.png", severity=30)
        s.put()

        data = s.rest("/api")
        self.assertEquals(data["level"], "WARNING")
开发者ID:2do,项目名称:stashboard,代码行数:7,代码来源:test_status.py

示例10: data

    def data(self):
        services = []
        default_status = Status.get_default()

        lists = []
        for list in self.lists:
            l = List.get_by_slug(list)
            if l is not None:
                lists.append(l)

        for service in Service.all().filter("list IN", lists).order("name").fetch(100):
            event = service.current_event()
            if event is not None:
                status = event.status
            else:
                status = default_status

            if len(self.statuses) and not status.slug in self.statuses:
                continue

            today = date.today() + timedelta(days=1)
            current, = service.history(1, default_status, start=today)
            has_issues = current["information"] and status.key() == default_status.key()

            service_dict = {
                "slug": service.slug,
                "name": service.name,
                "url": service.url(),
                "status": status,
                "has_issues": has_issues,
                "history": service.history(5, default_status),
            }
            services.append(service_dict)

        return {"days": get_past_days(5), "statuses": Status.all().fetch(100), "services": services}
开发者ID:azenk,项目名称:stashboard,代码行数:35,代码来源:site.py

示例11: get_status

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,代码行数:8,代码来源:views.py

示例12: status_add

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,代码行数:8,代码来源:views.py

示例13: home

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,代码行数:9,代码来源:views.py

示例14: test_history_no_errors_boundary

    def test_history_no_errors_boundary(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 4, 5)
        event = Event(status=down, service=self.service, start=now, message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))
        self.assertEquals(history[0]["information"], False)
开发者ID:2do,项目名称:stashboard,代码行数:10,代码来源:test_history.py

示例15: post

	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,代码行数:11,代码来源:views.py


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