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


Python models.Activity类代码示例

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


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

示例1: get

	def get(self, *args):
		respo = self.response.out.write
		output = self.dbg
		
		respo ("<html><head><title>Test</title></head><body>")
		if (self.request.path.endswith('/clean')):
			output ("Begin Clean Up")
			self.cleanUp()
			output ("Cleaning up done")
			return
		output("Now let's go")
		billList = [('Cort', '75.5'), ('Balls', '15')]
		output ("BillList: ", billList)
		
		allacts = Activity.all()
		for act in allacts:
			bill = act.bill
			for entry in bill:
				output ("Entry:", entry, ",", lb = False)
			output()
			output ("acts:", act.key().id(), "Total Expense:", act.expense, "Expanse Bill: ", bill)
		
		mem = Membership.all().get()
		output ("New activity")
		act = Activity(name = "test act", duration=2.0, organizer = mem.user, club = mem.club, bill = billList, expense = '100' )
		output ("Expense:", act.expense)
		output ("Bill:", act.bill)
		output ("Now, put")
		key = act.put()
		output ("Act Saved: ", act.is_saved(), "Key is ", key, " Id is", key.id())
		respo("</body></html>")
开发者ID:cardmaster,项目名称:makeclub,代码行数:31,代码来源:test.py

示例2: WritingOff

def WritingOff(request, id_number):
    try:
        project = Object.objects.get(id=int(id_number))
    except ObjectDoesNotExist:
        return HttpResponse('Об’єкт не існує.<br>Спробуйте інший id.')

    if request.method == 'POST':
        form = WritingOffForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            act = Activity(time_stamp=dt.now(), aim = project, type='Списання', actor=Custom.myUser.objects.get(username=request.user.username))
            act.save()
            project.save()
            for (k, v) in cd.items():
                if k=='material':
                    v = unicode(v[1:-1].replace('u\'', '').replace('\'', ''))
                attr_assign = AttributeAssignment(attr_name=k, attr_value=v, attr_label=form.fields[k].label,
                                                  event_initiator=act, aim=project)
                attr_assign.save()
            return HttpResponseRedirect('/')
        else:
            return render(request, 'AddOnTs.html', {'form': form, 'errors': form.errors})
    else:
        ps_code = get_attrib_assigns('Приймання на постійне зберігання', project, 'PS_code')
        inventory_number = get_attrib_assigns('Інвентарний облік', project, 'inventory_number')
        spec_inventory_numb = get_attrib_assigns('Спеціальний інвентарний облік', project, 'spec_inventory_numb')
        ts_code = get_attrib_assigns('Приймання на тимчасове зберігання', project, 'TS_code')
        data = {'name': project.name, 'is_fragment': project.is_fragment, 'amount': project.amount,
                'note': project.note, 'PS_code': ps_code, 'inventory_number': inventory_number,
                'spec_inventory_numb': spec_inventory_numb, 'TS_code': ts_code,
                }
        form = WritingOffForm(initial=data)
    return render(request, 'AddOnTs.html', {'form': form, 'label': 'Списати об’єкт'})
开发者ID:demvy,项目名称:museum,代码行数:33,代码来源:views.py

示例3: _parse_activities_response

    def _parse_activities_response(self, jsonBody):
        """

        """

        activities = []
        
        data = json.loads(str(jsonBody))
        for activity in data['data']:
            # Create a new activity
            a = Activity(id=activity['id'], version=activity['version'])
            # Get the coords and set the geometry
            # Check first the geometry type
            # Handle MultiPoint geometries
            if activity['geometry']['type'].lower() == "multipoint":
                points = []
                for coords in activity['geometry']['coordinates']:
                    points.append(QgsPoint(coords[0], coords[1]))
                a.setGeometry(QgsGeometry.fromMultiPoint(points))
            # Handle Point geometries
            if activity['geometry']['type'].lower() == "point":
                coords = activity['geometry']['coordinates']
                a.setGeometry(QgsGeometry.fromPoint(QgsPoint(coords[0], coords[1])))

            # Append it to the list
            activities.append(a)

        return activities
开发者ID:CDE-UNIBE,项目名称:lo-editor2,代码行数:28,代码来源:OlaInterfaceDialog.py

示例4: login_User

def login_User(request):
    if request.method == "POST":
        username = request.POST['username']
        password = request.POST['password']
        user = authenticate(username=username, password=password)

        if user != None:
            if user.is_active == True:
                userprofile = user.userprofile

                login(request, user)
                messages.success(request, 'Welcome, %s!' % (username))
                Activity.log_activity("ACTIVITY_LOGIN", user.userprofile)
                next_url = request.GET.get('next', URL_HOME)

                if "//" in next_url and re.match(r'[^\?]*//', next_url):
                    next_url = settings.LOGIN_REDIRECT_URL
                return redirect(next_url)

            else:
                messages.error(request, "You haven't activated your account yet. Please check your email.")
        else:
            messages.error(request, 'Invalid Login credentials. Please try again.')

    next_path = request.GET.get('next', URL_HOME)
    form = AuthenticationForm()
    return render_to_response(HTML_LOGIN, {'form':form}, RequestContext(request, {'next': next_path}))
开发者ID:Project-EPIC,项目名称:emergencypetmatcher,代码行数:27,代码来源:views.py

示例5: TempSave

def TempSave(request, id_number=0):
    try:
        project = Object.objects.get(id=int(id_number))
    except ObjectDoesNotExist:
        if id_number != 0:
            return HttpResponse('Об’єкт не існує.<br>Спробуйте інший id.')
        else:
            project = Object(name='Новий')
    if request.method == 'POST':
        form = TempSaveForm(request.POST, request.FILES)
        if form.is_valid():
            cd = form.cleaned_data
            act = Activity(time_stamp=dt.now(), aim=project, type='Приймання на тимчасове зберігання', actor=Custom.myUser.objects.get(username=request.user.username))
            act.save()
            project.reason = cd['reason']
            project.save()
            for (k, v) in cd.items():
                if k=='material':
                    v = unicode(v[1:-1].replace('u\'', '').replace('\'', ''))
                attr_assign = AttributeAssignment(attr_name=k, attr_value=v, attr_label=form.fields[k].label,
                                                  event_initiator=act, aim=project)
                attr_assign.save()
            return HttpResponseRedirect('/')
        else:
            return render(request, 'AddOnTs.html', {'form': form})
    else:
        data = {'name': project.name, 'is_fragment': project.is_fragment, 'amount': project.amount,
                'date_creation': project.date_creation, 'place_of_creation': project.place_of_creation,
                'author': project.author, 'technique': project.technique, 'material': project.material.decode('unicode-escape').split(', '),
                'size': project.size, 'condition': project.condition, 'condition_descr': project.condition_descr, 'description': project.description,
                'price': project.price, 'note': project.note}
        form = TempSaveForm(initial=data)
        return render(request, 'AddOnTs.html', {'form': form, 'label': 'Прийняти об’єкт на ТЗ'})
开发者ID:demvy,项目名称:museum,代码行数:33,代码来源:views.py

示例6: chooseActivity

def chooseActivity(request):
	if request.method=='POST':
		
		#OK this is super not the way to do this, but oh well
		#also, may end up trying to add an activity and not be able to
		#super confusing probably, not at all the right way to do things
		pvalues=request.POST.copy()
		if not request.POST['activity']:
			if len(request.POST['add_activity']):
				newActivity=Activity(name=request.POST['add_activity'])
				newActivity.save(request)
				pvalues['activity']=newActivity.id
		aform=ActivityChooseForm(pvalues, request=request)

		if aform.is_valid():
			aRating=aform.save(commit=False)
			aRating.preDateTime=datetime.datetime.now()
			aRating.save(request)
			rform=ActivityRatingForm(instance=aRating)
			pk=aRating.id
			redirectURL='/activity/'+str(pk)+'/rate/'
			return redirect(redirectURL) 
		else:
			return render(request, 'activity/choose.html', {'aform':aform})
	aform=ActivityChooseForm(request=request)
	return render(request, 'activity/choose.html',{'aform':aform})
开发者ID:icnivad,项目名称:kibun,代码行数:26,代码来源:views.py

示例7: FromPSToTS

def FromPSToTS(request, id_number):
    try:
        project = Object.objects.get(id=int(id_number))
    except ObjectDoesNotExist:
        return HttpResponse('Об’єкт не існує.<br>Спробуйте інший id.')

    if request.method == 'POST':
        form = FromPStoTSForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            act = Activity(time_stamp=dt.now(), aim = project, type='Видача предметів з Постійного зберігання на Тимчасове зберігання', actor=Custom.myUser.objects.get(username=request.user.username))
            act.save()
            project.save()
            for (k, v) in cd.items():
                if k=='material':
                    v = unicode(v[1:-1].replace('u\'', '').replace('\'', ''))
                attr_assign = AttributeAssignment(attr_name=k, attr_value=v, attr_label=form.fields[k].label,
                                                  event_initiator=act, aim=project)
                attr_assign.save()
            return HttpResponseRedirect('/')
        else:
            return render(request, 'AddOnTs.html', {'form': form, 'errors': form.errors})
    else:
        ps_code = get_attrib_assigns('Приймання на постійне зберігання', project, 'PS_code')
        inventory_number = get_attrib_assigns('Інвентарний облік', project, 'inventory_number')
        data = {'name': project.name, 'is_fragment': project.is_fragment, 'amount': project.amount,
                'date_creation': project.date_creation, 'place_of_creation': project.place_of_creation,
                'author': project.author, 'technique': project.technique, 'material': project.material.decode('unicode-escape').split(', '),
                'size': project.size, 'description': project.description, 'note': project.note,
                'condition': project.condition, 'condition_descr': project.condition_descr,
                'PS_code': ps_code, 'inventory_number': inventory_number,
                }
        form = FromPStoTSForm(initial=data)
    return render(request, 'AddOnTs.html', {'form': form, 'label': 'Видати об’єкт з ПЗ на ТЗ'})
开发者ID:demvy,项目名称:museum,代码行数:34,代码来源:views.py

示例8: activity

def activity(r, u='', action='', group=''):
    timestamp = datetime.now().strftime('%Y%m%d%H%M%S')
    act = Activity(believer=u, group=group, timestamp=timestamp,
                   action=action, ipaddress=IP(r),
                   source='web', category='track')
    act.save(True)
    return 'OK'
开发者ID:dalinhuang,项目名称:demodemo,代码行数:7,代码来源:views.py

示例9: rateCivi

def rateCivi(request):
    civi_id = request.POST.get('civi_id', '')
    rating = request.POST.get('rating', '')
    account = Account.objects.get(user=request.user)

    c = Civi.objects.get(id=civi_id)

    try:
        prev_act = Activity.objects.get(civi=c, account=account)
    except Activity.DoesNotExist:
        prev_act = None

    try:


        activity_data = {
            'account': account,
            'thread': c.thread,
            'civi': c,
        }

        if rating == "vneg":
            c.votes_vneg = c.votes_vneg + 1
            vote_val = 'vote_vneg'
        elif rating == "neg":
            c.votes_neg = c.votes_neg + 1
            vote_val = 'vote_neg'
        elif rating == "neutral":
            c.votes_neutral = c.votes_neutral + 1
            vote_val = 'vote_neutral'
        elif rating == "pos":
            c.votes_pos = c.votes_pos + 1
            vote_val = 'vote_pos'
        elif rating == "vpos":
            # c.votes_vpos = c.votes_vpos + 1
            vote_val = 'vote_vpos'
        activity_data['activity_type'] = vote_val

        c.save()

        if prev_act:
            prev_act.activity_type = vote_val
            prev_act.save()
            data = {
                'civi_id':prev_act.civi.id,
                'activity_type': prev_act.activity_type,
                'c_type': prev_act.civi.c_type
            }
        else:
            act = Activity(**activity_data)
            act.save()
            data = {
                'civi_id':act.civi.id,
                'activity_type': act.activity_type,
                'c_type': act.civi.c_type
            }
        return JsonResponse({'data' : data})
    except Exception as e:
        return HttpResponseServerError(reason=str(e))
开发者ID:CiviWikiorg,项目名称:CiviWiki,代码行数:59,代码来源:write.py

示例10: register_activity

def register_activity(request, time='', data='', client=''):
    carrier, created = Carrier.objects.get_or_create(data=data) 
 
    if carrier.is_registered():
        Activity.create(time, client, carrier)
        return HttpResponse(status=200)
    else:
        return HttpResponse(status=403)
开发者ID:RadoRado,项目名称:checkin-at-fmi,代码行数:8,代码来源:views.py

示例11: auto_checkout

def auto_checkout():
    active_checkins = Checkin.checkins.active()
    for checkin in active_checkins:
        auto_checkout_activity = Activity()
        auto_checkout_activity = checkin.checkin_activity
        auto_checkout_activity.time = datetime.datetime.now()
        auto_checkout_activity.save()
        checkin.checkout_activity = auto_checkout_activity
        checkin.save()
开发者ID:RadoRado,项目名称:checkin-at-fmi,代码行数:9,代码来源:cron.py

示例12: create_activity

def create_activity(activity_type, lead=None, job=None):
	description = None
	lead_key = None
	job_key = None

	if job is not None and job.key is not None:
		job_key = job.key

	if lead is not None and lead.key is not None:
		lead_key = lead.key
	else:
		if job is not None and job.lead is not None:
			lead_key = job.lead


	if activity_type == 'LEAD_SENT':
		description = _build_lead_sent_description(lead.to_json())
	elif activity_type == 'LEAD_READ':
		description = _build_lead_read_description(lead)
	elif activity_type == 'LEAD_CLICKED':
		description = _build_lead_clicked_description(lead)
	elif activity_type == 'LEAD_PENDING_PAYMENT':
		description = _build_lead_pending_payment_description(lead)
	elif activity_type == 'LEAD_CONVERTED':
		description = _build_lead_converted_description(lead)
	elif activity_type == 'JOB_CREATED':
		Activity.set_job_in_all_lead_activities(job)
		description = _build_job_created_description(job)
	elif activity_type == 'JOB_ASSIGNED':
		description = 'The job has been taken by a Flixer'
	elif activity_type == 'JOB_CANCELLED_BY_FLIXER':
		description = 'The job has been cancelled by the flixer'
	elif activity_type == 'JOB_CANCELLED_BY_PROPERTY_OWNER':
		description = 'The job has been cancelled by the property owner'
	elif activity_type == 'JOB_RESCHEDULED':
		description = 'The job has been rescheduled by the property owner'
	elif activity_type == 'JOB_PUBLISHING_STARTED':
		description = 'The job publishing has been started'
	elif activity_type == 'JOB_PUBLISHING_DONE':
		description = 'The job publishing has been done'
	elif activity_type == 'JOB_PUBLISHING_REDO_DONE':
		description = 'The job fixes publishing has been done'
	elif activity_type == 'JOB_REPROVED':
		description = 'The property owner has reproved the job'
	elif activity_type == 'JOB_APPROVED':
		description = 'The property owner has approved the job'
	elif activity_type == 'JOB_PUBLISHED_AT_VALUEGAIA':
		description = 'The job has been published at ValueGaia'
	elif activity_type == 'JOB_FINISHED':
		description = 'The job has been finished'


	if description is not None:
		Activity.create(description, activity_type, lead_key=lead_key, job_key=job_key)

	return True
开发者ID:jesse1983,项目名称:pymay,代码行数:56,代码来源:activity_helper.py

示例13: challenge_count

def challenge_count(player, days=None):
    """
     Return the count of challenges played by player in the last x _days_.
     All challenges if days == None
    """
    if not days:
        return Activity.get_player_activity(player).filter(action__contains='chall').count()
    start = datetime.now() - timedelta(days=days)
    return Activity.get_player_activity(player).filter(
            action__contains='chall', timestamp__gte=start).count()
开发者ID:AndreiRO,项目名称:wouso,代码行数:10,代码来源:achievements.py

示例14: logout_User

def logout_User(request):
    # Update last_logout date field
    user = get_object_or_404(UserProfile, pk=request.user.userprofile.id)
    user.last_logout = datetime.now()
    user.save()

    Activity.log_activity("ACTIVITY_LOGOUT", request.user.userprofile)
    messages.success(request, "See you next time!")
    logout(request)
    return redirect(URL_HOME)
开发者ID:Project-EPIC,项目名称:emergencypetmatcher,代码行数:10,代码来源:views.py

示例15: update_visibility

def update_visibility(aid):
    """
    Pulls the existing activity and then pushes it again
    
    """
    logger.warning('update_visibility aid:%s' % aid)
    logger.warning('update_visibility aid:%s pulling' % aid)
    Activity.pull(aid, confirmed = False)
    logger.warning('update_visibility aid:%s pushing' % aid)
    push_activity(aid)
    logger.warning('update_visibility aid:%s pushed' % aid)
开发者ID:pchennz,项目名称:KEEN-full,代码行数:11,代码来源:tasks.py


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