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


Python models.Member类代码示例

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


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


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