• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Member类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_march30_minus_1

 def test_march30_minus_1(self):
     # 1 month before March 30 is February 28
     self.assertEqual(Member.add_n_months(date(2015, 3, 30), -1),
                      date(2015, 2, 28))
     # or February 29
     self.assertEqual(Member.add_n_months(date(2016, 3, 30), -1),
                      date(2016, 2, 29))
开发者ID:rtucker,项目名称:django-mms,代码行数:7,代码来源:tests.py


示例2: create_or_login

def create_or_login(request):
    if not request.method == "POST":
        return HttpResponseRedirect(reverse(list))
    form = EmailForm(request.POST)
    if not form.is_valid():
        return render(request, "members/login.html", {"form": form})
    data = form.cleaned_data
    member = get_object_or_None(Member, email=data["email"])
    if not member:
        member = Member(email=data["email"])
        member.save()
    member_url = reverse(edit, kwargs={"key": member.key})
    token_gen = PasswordResetTokenGenerator()
    token = token_gen.make_token(member)
    try:
        send_mail(
            "Your Nick Reid Directory Profile",
            "Follow this link to update your profile: %s?token=%s" % (member_url, token),
            "[email protected]",
            [member.email],
            fail_silently=False,
        )
    except:
        messages.error(request, "There was an error sending email to %s", member.email)
    messages.success(request, "An email has been sent to %s." % (member.email))
    return HttpResponseRedirect(reverse(list))
开发者ID:nickdotreid,项目名称:directory,代码行数:26,代码来源:views.py


示例3: test_dec30_plus_2

 def test_dec30_plus_2(self):
     # 2 months after December 30 is February 28
     self.assertEqual(Member.add_n_months(date(2014, 12, 30), 2),
                      date(2015, 2, 28))
     # or February 29
     self.assertEqual(Member.add_n_months(date(2015, 12, 30), 2),
                      date(2016, 2, 29))
开发者ID:rtucker,项目名称:django-mms,代码行数:7,代码来源:tests.py


示例4: test_create_member_method

    def test_create_member_method(self):
        m = Member(last_name='Bugglesworth', first_name='Paul', title="Dr.", member=True, registered=False)
        self.assertEqual(m.last_name, 'Bugglesworth')

        member_start_count = Member.objects.count()
        m.save()
        Member.objects.create(last_name="Lennon", first_name="John", member=True, registered=True)
        member_end_count = Member.objects.count()
        self.assertEqual(member_end_count, member_start_count+2)
开发者ID:dennereed,项目名称:paleoanthro,代码行数:9,代码来源:tests.py


示例5: _home

def _home(request, db=None, ctx=None):
    t = loader.get_template('home.html')
    ctx['summary'] = OrderedDict([
        ('Waiting', counts(Member.waiters())),
        ('Elfin', counts(Member.elfins())),
        ('Woodchip', counts(Member.woodchips())),
        ('Carer', counts(Member.carers())),
    ])
    ctx['Member'] = Member

    return HttpResponse(t.render(RequestContext(request, ctx)))
开发者ID:timp21337,项目名称:membership,代码行数:11,代码来源:views.py


示例6: create

def create():
    if 'app-key' not in request.headers:
        response = jsonify({'code': 401, 'message': 'App-Key header is required.'})
        response.status_code = 401
        return response

    application = Application.find_by_key(request.headers['app-key'])
    if not application:
        response = jsonify({'code': 401, 'message': 'Invalid App-key.'})
        response.status_code = 401
        return response

    g.application = application

    form = OrganizationCreateForm(request.form)
    if not form.validate():
        return form.errors_as_json()

    plan = ApplicationPlan.find_by_id(form.application_plan_id.data)
    if not plan:
        form.errors['application_plan_id'] = ['No application plan found..']
        return form.errors_as_json()

    check = Organization.query.filter(Organization.name == form.name.data).first()
    if check:
        form.errors['name'] = ['Name is already taken.']
        return form.errors_as_json()

    organization = Organization(**{
        'name': form.name.data,
        'display': form.display.data,
        'description': form.description.data,
        'website': form.description.data,
        'removed': form.removed.data,
        'currency': form.currency.data.upper(),
        'application_plan_id': form.application_plan_id.data,
        'application_id': g.application.id
    })
    organization.save()

    member = Member(**{
        'display': Member.display_from_email(form.member_email.data),
        'email': form.member_email.data,
        'password': bcrypt.hashpw(form.member_password.data, bcrypt.gensalt()),
        'organization_id': organization.id,
        'status': 'MEMBER',
        'admin': True
    })

    member.save()

    return jsonify(organization.to_json()), 201
开发者ID:2Leadin,项目名称:api-flask,代码行数:52,代码来源:views.py


示例7: member_edit

def member_edit():
    """
    """
    form = MemberForm()
    if form.validate_on_submit():
        member = Member(firstname = form.firstname.data,
                    lastname = form.lastname.data,
                    location = form.location.data,
                    user = users.get_current_user())
        member.put()
        flash('Member saved on database.')
        return redirect(url_for('member_list'))
    return render_template('members/edit.html', form=form)
开发者ID:johnmontero,项目名称:pypewe,代码行数:13,代码来源:views.py


示例8: save_keypair

def save_keypair(request):
    public_key = request.POST['public-key']
    private_key = request.POST['private-key']
    try:
        member = request.user.member
        member.private_key = private_key
        member.public_key = public_key
        member.save()
    except Member.DoesNotExist:
        # New user
        member = Member(public_key=public_key, private_key=private_key, user=request.user)
        member.save()

    return JsonResponse({'foo': 'bar'})
开发者ID:michel-cf,项目名称:taggy,代码行数:14,代码来源:views.py


示例9: post

 def post(self, request, *args, **kwargs):
     self.object = self.get_object()
     form_class = self.get_form_class()
     form = MemberImportForm(user=self.object)
     c_in = request.POST.get('c_in')
     c_out = request.POST.get('c_out')
     if c_in:
         member = Member.objects.get(id=c_in)
     elif c_out:
         member = Member.objects.get(id=c_out)
     else:
         member = Member()
     member.user = self.object
     member.save()
     return HttpResponseRedirect(reverse('user_edit'));
开发者ID:Cerkinfo,项目名称:Site,代码行数:15,代码来源:views.py


示例10: desktop_verify_parking_permit

def desktop_verify_parking_permit(request):

    if request.method == "POST":
        owner = request.user
        try:

            # Process the email address the owner provided.
            owner_email = request.session.get("owner_email")
            if owner.email == "":
                owner.email == owner_email
                owner.save()
            elif owner.email != owner_email:
                pass
                # TODO: Save as an alternate email (member app) and log as a WARNING or INFO?

            # Create the parking permit in the database
            perm = ParkingPermit.objects.create(
                owner=request.user.member,
                short_desc=request.session.get("short_desc"),
                ok_to_move=request.session.get("ok_to_move"),
                approving_member=Member.get_local_member(request.session.get("approving_member_username")),
            )

            _clear_session(request)
            return HttpResponse("SUCCESS " + str(perm.pk))

        except Exception as e:
            return HttpResponse("ERROR " + str(e))

    else:  # For GET and any other methods:
        return render(request, "inventory/desktop-parking-permit-verify.html")
开发者ID:adrianboyko,项目名称:xerocraft-django,代码行数:31,代码来源:views.py


示例11: validate_client_id

    def validate_client_id(form, field):
        if not field.data:
            return

        member = Member.find_by_id(field.data)
        if not member:
            raise ValidationError('Client not found.')
开发者ID:2Leadin,项目名称:api-flask,代码行数:7,代码来源:forms.py


示例12: upload_file

def upload_file(request):
    """Creates a view to upload a file and read the contents, if the uploaded file is\
    a zip file, file is first extracted and read. the file is read and updates the data\
    to database. if the corresponding group is not present, a new group is created and updated."""
    x = {}
    y = []
    s = []
    if request.method == "POST":
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            title = form.files["file"]
            filename = str(title)
            x = request.FILES
            front = filename.split(".")[0]
            if filename.endswith(".zip"):
                zipf = zipfile.ZipFile(x["file"])
                zipf.extractall(os.getcwd())
            else:
                y = x["file"].read()
            z = "" + front + ".xlsx"
            path = default_storage.save(z, ContentFile(y))
            tmp_file = os.path.join(settings.MEDIA_ROOT, path)
            if form.is_valid():
                workbook = xlrd.open_workbook(z)
                sh = workbook.sheet_by_name("Sheet1")
                for rownum in range(sh.nrows):
                    member = Member()
                    member.firstname = sh.row_values(rownum)[0]
                    member.lastname = sh.row_values(rownum)[1]
                    member.dob = sh.row_values(rownum)[2]
                    member.gender = sh.row_values(rownum)[3]
                    member.organisation = sh.row_values(rownum)[4]
                    member.email = sh.row_values(rownum)[5]
                    code = str(sh.row_values(rownum)[6])
                    group, status = Group.objects.get_or_create(group_code=code)
                    member.group = group
                    member.save()

                os.chdir(os.getcwd())
                files = glob.glob("*.xlsx")
                for filename in files:
                    os.unlink(filename)
            return HttpResponseRedirect(reverse("index"))
    else:
        form = UploadFileForm()
    return render(request, "contacts/read.html", {"form": form})
开发者ID:sreekanthkaralmanna,项目名称:Manage-Contacts,代码行数:46,代码来源:views.py


示例13: _members

def _members(request, db=None, ctx={}):
    t = loader.get_template('members.html')
    try:
        status = request.REQUEST['status']
    except StandardError:
        status = 'Elfin'
    ctx['status'] = status
    ctx['members'] = Member.members_with_status(status)
    return HttpResponse(t.render(RequestContext(request, ctx)))
开发者ID:timp21337,项目名称:membership,代码行数:9,代码来源:views.py


示例14: authenticate

    def authenticate(self, username=None, password=None):
        identifier = username  # Given username is actually a more generic identifier.

        user = Member.get_local_user(identifier)
        if user is None:
            return None
        elif user.check_password(password):
            return user
        else:
            return None
开发者ID:SRCprogramming,项目名称:cirqueroots-django,代码行数:10,代码来源:authenticators.py


示例15: kiosk_identify_subject

def kiosk_identify_subject(request, staff_card_str, next_url):

    member = Member.get_by_card_str(staff_card_str)
    if member is None or not member.is_domain_staff():
        return render(request, 'members/kiosk-invalid-card.html', {})  # TODO: use kiosk-domain-error template?

    params = {
        "staff_card_str" : staff_card_str,
        "next_url" : next_url
    }
    return render(request, 'members/kiosk-identify-subject.html', params)
开发者ID:adrianboyko,项目名称:xerocraft-django,代码行数:11,代码来源:views.py


示例16: kiosk_staff_menu

def kiosk_staff_menu(request, member_card_str):

    member = Member.get_by_card_str(member_card_str)
    if member is None or not member.is_domain_staff():
        return render(request, 'members/kiosk-invalid-card.html', {})  # TODO: use kiosk-domain-error template?

    params = {
        "memb_fname" : member.first_name,
        "memb_card_str" : member_card_str
    }
    return render(request, 'members/kiosk-staff-menu.html', params)
开发者ID:adrianboyko,项目名称:xerocraft-django,代码行数:11,代码来源:views.py


示例17: create_new_member_and_pass

def create_new_member_and_pass( clean_new_member_data ):
    ### Create the Member Instance ###
    # create the dictionary of attributes relevant to the member model
    member_dict = {k:v for k,v in clean_new_member_data.items() if k not in ['member_type', 'is_reserved', 'reserved_id']}
    #print member_dict
    member = Member( **member_dict )
    member.save()
    
    ### Create the Pass instance ###
    # Don't create a pass for Trip-Only Members
    current_season = get_current_season()
    is_reserved = clean_new_member_data['is_reserved']
    # if signed up as reserved, use that reserved id
    if ( is_reserved ):
        active_id = clean_new_member_data['reserved_id']
    # else give them the lowest active id for the season, which is greater than 25
    # this should fill in holes if someone gets deleted
    else:
        pass_set = Pass.objects.filter(season=current_season, active_id__gte=26)
        active_set = { p.active_id for p in pass_set}
        if ( len(active_set) == 0 ): active_id = 26 # first non-reserved member of the season
        else:
            active_range = range(26, max(active_set))
            active_id = max(active_set) + 1 # set to the max + 1
            # unless we find an empty space
            for i in active_range:
                if i not in active_set: # if we find one in the range, but not in the set
                    active_id = i # use that empty space
                    break
    
    if clean_new_member_data['member_type'].member_type == "TRIP": active_id= None
    member_pass = Pass( member=member, season=current_season,
                        active_id=active_id, is_reserved=is_reserved,
                        member_type=clean_new_member_data['member_type'],
                        price_paid=get_price_paid(clean_new_member_data['member_type']),
                        photo=member.photo)
    # add them to the database
    member_pass.save()
    
    return member.id
开发者ID:teffland,项目名称:schussapp,代码行数:40,代码来源:views.py


示例18: _log_visit_event

def _log_visit_event(member_card_str, event_type):

    is_valid_evt = event_type in [x for (x, _) in VisitEvent.VISIT_EVENT_CHOICES]
    if not is_valid_evt:
        return False, "Invalid event type."

    member = Member.get_by_card_str(member_card_str)
    if member is None:
        return False, "No matching member found."
    else:
        VisitEvent.objects.create(who=member, event_type=event_type)
        _inform_other_systems_of_checkin(member, event_type)
        return True, member
开发者ID:adrianboyko,项目名称:xerocraft-django,代码行数:13,代码来源:views.py


示例19: _session

def _session(request, db=None, ctx={}):
    try:
        name = request.REQUEST['name']
    except StandardError:
        name = None
        t = loader.get_template('session.html')
        ctx['SessionChoiceForm'] = forms.SessionChoiceForm()
        ctx['sessions'] = Session.objects.all()

        return HttpResponse(t.render(RequestContext(request, ctx)))
    t = loader.get_template('members.html')
    ctx['members'] = Member.attendees(name)
    return HttpResponse(t.render(RequestContext(request, ctx)))
开发者ID:timp21337,项目名称:membership,代码行数:13,代码来源:views.py


示例20: validate_member_id

    def validate_member_id(form, field):
        from members.models import Member
        
        if request.method == 'POST':
            if not form.member_id.data:
                raise ValidationError(field.gettext('This field is required.'))

            field.member = Member.find_by_id(field.data)
            if not member:
                raise ValidationError('Member not found.')

        else:
            field.data = None
开发者ID:2Leadin,项目名称:api-flask,代码行数:13,代码来源:forms.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python membership.Membership类代码示例发布时间:2022-05-27
下一篇:
Python spatial_helper.SpatialHelper类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap