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


Python Member.save方法代码示例

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


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

示例1: create_or_login

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
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,代码行数:28,代码来源:views.py

示例2: test_create_member_method

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
    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,代码行数:11,代码来源:tests.py

示例3: import_data

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
def import_data(ty,data):

#TODO

  error = False
#  for line in csv.DictReader(data,delimiter='\t',quoting=csv.QUOTE_NONE):
  for l in csv.DictReader(data.read().splitlines(),delimiter=';',quoting=csv.QUOTE_NONE):
#  for line in c_data:
#    l = findall(r'\"(.+?)\"',str(line))
#  for line in c_data:
#    l = findall(r'\"(.+?)\"',str(line))

    Model = None
    try:
      if ty == "members":
#       Model = Member.objects.get(first_name=l[1],last_name=l[0],email=l[6])
        Model = Member.objects.get(first_name=unicode(l['VIRNUMM']),last_name=unicode(l['NUMM']),email=unicode(l['EMAIL']))
      if ty == "calendar": Model = Meeting.objects.get(title=unicode(l[0]),when=unicode(l[1]),time=unicode(l[2]))
    except:
      if ty == "members":
        A = Address (
                address         = unicode(l['ADRESS']),
                postal_code     = unicode(l['CP']),
                location        = unicode(l['DUERF']),
                country         = unicode(l['LAND'])
        )
        Model = Member (
                        first_name      = unicode(l['VIRNUMM']),
                        last_name       = unicode(l['NUMM']),
                        address         = A,
                        email           = unicode(l['EMAIL'])
                )
        # create user
        user = User.objects.create_user(gen_username(Model.first_name,Model.last_name), Model.email, make_password(gen_random_password()))
        Model.user = user
      if ty == "calendar":
        Model = Meeting (
                        title           = unicode(l[0]),
                        when            = unicode(l[1]),
                        time            = unicode(l[2])
                )

        # check/create location
        location = None
        try:
          location = Location.objects.get(name=l[3])
        except Location.DoesNotExist:
          location = Location (name=l[3])

        Model.location = location

      Model.save()

  return error
开发者ID:psteichen,项目名称:clusil-intranet,代码行数:56,代码来源:functions.py

示例4: create

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
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,代码行数:54,代码来源:views.py

示例5: save_keypair

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
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,代码行数:16,代码来源:views.py

示例6: post

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
 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,代码行数:17,代码来源:views.py

示例7: upload_file

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
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,代码行数:48,代码来源:views.py

示例8: member

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
def member(request):
    """Creates a view to add members to database, if the group code exists,\
    add the user to that group or else create a new group and save."""
    members = Member.objects.all()
    groups = Group.objects.all()
    if request.method == "POST":
        form = MemberForm(request.POST)
        if form.is_valid():
            firstname = form.cleaned_data["firstname"]
            lastname = form.cleaned_data["lastname"]
            dob = form.cleaned_data["dob"]
            gender = form.cleaned_data["gender"]
            organisation = form.cleaned_data["organisation"]
            email = form.cleaned_data["email"]
            options = request.POST.getlist("group")
            new_code = request.POST["new_group"]
            name = request.POST["name"]
            description = request.POST["description"]
            try:
                member = Member()
                member.firstname = firstname
                member.lastname = lastname
                member.dob = dob
                member.gender = gender
                member.organisation = organisation
                member.email = request.POST["email"]
                grp_codes = [str(x) for x in options]
                for cd in grp_codes:
                    if cd:
                        gr = Group.objects.get(group_code=cd)
                        member.group = gr
                g, status = Group.objects.get_or_create(group_code=new_code)
                g.name = name
                g.description = description
                member.group = g
                member.save()
            except:
                pass
            return HttpResponseRedirect(reverse("index"))
    else:
        form = MemberForm()
    context = {"members": members, "groups": groups, "form": form}
    return render(request, "members/member.html", context)
开发者ID:sreekanthkaralmanna,项目名称:Manage-Contacts,代码行数:45,代码来源:views.py

示例9: create_new_member_and_pass

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
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,代码行数:42,代码来源:views.py

示例10: SurvivorRegistration

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
def SurvivorRegistration(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/home')
    if request.method == "POST":
        form = RegistrationForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(username=form.cleaned_data["username"],
                                            email=form.cleaned_data["email"],
                                            password=form.cleaned_data["password"])
            user.save()
            member = Member(
                user=user, ign=form.cleaned_data["ign"], title="Player")
            member.save()
            return HttpResponseRedirect('/home')
        else:
            return render_to_response("register.html", {"form": form},
                                      context_instance=RequestContext(request))
    else:
        # user is not submitting the form, show them a registration form
        form = RegistrationForm()
        context = {"form": form}
        return render_to_response('register.html', context,
                                  context_instance=RequestContext(request))
开发者ID:Dachckol,项目名称:ReachNetwork,代码行数:25,代码来源:views.py

示例11: get_wsgi_application

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
import os
import yaml
from django.core.wsgi import get_wsgi_application
os.environ['DJANGO_SETTINGS_MODULE'] = 'portal.settings'
application = get_wsgi_application()

from django.contrib.auth.models import User
from members.models import Member


#
# create members for all members in backup yaml file
#
yaml_input = open("rails_members.yaml", 'r')
yaml_input = yaml.load(yaml_input)

for member in yaml_input:
	#
	# create a new member
	#
	mem = Member(id= int(member['old_id']), name=member['name'], google_id = member['google_uid'])
	mem.save()
	
print type(yaml_input)
开发者ID:davidbliu,项目名称:pbl-portal-django,代码行数:26,代码来源:import_members.py

示例12: int

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
from groups.models import Group

t = int(raw_input('number of members you want to add:'))

import random, datetime

NAME_PREFIX = u'赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜'
NAME_SUFFIX = u'伟芳秀敏杰丹灵华兆婷超梁晗辉军越征凯腾江帆一中君盛丽群来未晨和刚明娜'

def get_rand(s):
    return s[random.randint(0, len(s) - 1)]

groups = Group.objects.all()

for i in range(t):
    m = Member()
    m.balance = round(random.random() * 1000)
    m.birthday = datetime.datetime.now() - datetime.timedelta(days=random.randint(0, 30000))
    m.gender = get_rand(('M', 'F'))
    m.group = get_rand(groups)
    for t in range(0, 18):
        m.identify_number += get_rand('0123456789')
    m.name = get_rand(NAME_PREFIX) + get_rand(NAME_SUFFIX);
    if random.randint(0, 2) == 1:
        m.name += get_rand(NAME_SUFFIX)
    m.point = random.randint(0, 200)
    m.valid = bool(random.randint(0, 1))
    m.valid_to = datetime.datetime.now() + datetime.timedelta(days=random.randint(0, 1000))
    m.set_password('naiziylx')
    m.save()
    print m
开发者ID:ComboZhc,项目名称:Library,代码行数:33,代码来源:add_members.py

示例13: import_data

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
def import_data(ty,data):
 
  nb=0
  ok = True
  errors = False
  for l in UnicodeDictReader(data,delimiter=';',quoting=csv.QUOTE_NONE):
    debug('upload',u'Line : '+str(l))

    Model = None
    if ty == 'members':  #import members
      try:
        Model = Member.objects.get(first_name=str(l['PRENOM']),last_name=str(l['NOM']),email=str(l['EMAIL']))
      except Member.DoesNotExist:
        Model = Member(
		first_name    = str(l['PRENOM']),
		last_name	= str(l['NOM']),
		address	= str(l['ADRESSE']),
		phone		= str(l['TEL']),
		mobile	= str(l['MOBILE']),
		email		= str(l['EMAIL'])
	)
        # create user
        U = create_user(Model.first_name,Model.last_name, Model.email)
        Model.user = U
        Model.save()
        nb+=1

    if ty == 'calendar': #import calendar
      deadline = timezone.make_aware(datetime.strptime(l['DATE'] + ' ' + l['HEURE'],"%Y-%m-%d %H:%M")-timedelta(hours=24),None)
      if l['TYPE'] == '0': #meeting
        debug('upload',u"it's a meeting")
        try:
          Model = Meeting.objects.get(when=str(l['DATE']),title=str(l['TITRE']))
        except Meeting.DoesNotExist:
          Model = Meeting(
		title  		= str(l['TITRE']),
		when		= str(l['DATE']),
		time		= str(l['HEURE']),
		deadline	= deadline,
	  )

      if l['TYPE'] == '1': #event
        debug('upload',u"it's an event")
        try:
          Model = Event.objects.get(when=str(l['DATE']),title=str(l['TITRE']))
        except Event.DoesNotExist:
          Model = Event (
		title  		= str(l['TITRE']),
		when		= str(l['DATE']),
		time		= str(l['HEURE']),
		deadline	= deadline,
	  )

      # check/create location
      location = None
      try:
        location = Location.objects.get(name=str(l['LIEU']))
      except Location.DoesNotExist:
        location = Location(name=str(l['LIEU']))
        location.save()

      Model.location = location
      if l['TYPE'] == '0':  #add num to meeting title
        latest = Meeting.objects.values().latest('num')
        next_num = latest['num'] + 1
        Model.num = next_num
        Model.title = str(next_num) + u'. ' + str(Model.title)
      Model.save()
      nb+=1

  if not ok: return errors
  else: return nb
开发者ID:psteichen,项目名称:aperta-cms,代码行数:74,代码来源:functions.py

示例14: signup_view

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
def signup_view(request):
    signupform1 = MemberSignupForm1()
    signupform2 = MemberSignupForm2()
    signupform3 = SecurityQuestionAnswerForm()
    
    mId = -1
    member = None
    try:
        mId = request.session['member_id']
        member = request.session['member']
    except:
        mId = -1
        member = None
    
    if request.method == 'POST':
        keypress = request.POST['keypress']
        
        if keypress == 'sign(me)up':
            isValidMemberSignupForm = False
            signupform1 = MemberSignupForm1(request.POST)
            signupform2 = MemberSignupForm2(request.POST)
            signupform3 = SecurityQuestionAnswerForm(request.POST)
            isValidMemberSignupForm = signupform1.is_valid() and signupform2.is_valid() and signupform3.is_valid()
            
            if isValidMemberSignupForm:
                username = signupform2.cleaned_data["username"]
                password = signupform2.cleaned_data["password"]
                email = signupform2.cleaned_data["email"]
                que1 = signupform3.cleaned_data["que1"]
                ans1 = signupform3.cleaned_data["ans1"]
                que2 = signupform3.cleaned_data["que2"]
                ans2 = signupform3.cleaned_data["ans2"]
                que3 = signupform3.cleaned_data["que3"]
                ans3 = signupform3.cleaned_data["ans3"]
                
                try:
                    print("Checking availability of entered username.")
                    newUser = User.objects.create_user(username, email, password)
                    newUser.first_name = signupform2.cleaned_data["first_name"]
                    newUser.last_name = signupform2.cleaned_data["last_name"]
                    #g = Group.objects.get(name=MEMBERS) 
                    #g.user_set.add(newUser)
                    newUser.save()
                    
                    if newUser.pk:
                        print("Signing up new user.")
                        phone = signupform1.cleaned_data["phone_no"]
                        address = signupform1.cleaned_data["address"]
                        dob = signupform1.cleaned_data["dob"]
                    
                        newMember = Member(user_id = newUser.id, phone_no = phone, address = address, dob = dob)
                        newMember.save()
                            
                        print("Created new member: %s_%s: mId#%d" % (newMember.user.first_name, newMember.user.last_name, newMember.user.id))

                        newMemberA1 = MemberAnswers(member=newMember, question=que1, answer=ans1)
                        newMemberA2 = MemberAnswers(member=newMember, question=que2, answer=ans2)
                        newMemberA3 = MemberAnswers(member=newMember, question=que3, answer=ans3)
                        newMemberA1.save()
                        newMemberA2.save()
                        newMemberA3.save()
                        
                        print("Recorded Security Question-Answers for Member :%s_%s" % (newMember.user.first_name, newMember.user.last_name))

                        request.session.flush()
#                         dictionary = add_csrf(request, form=MemberLoginForm())
                        return HttpResponseRedirect(reverse('members.views.login_view'))
                 
                    #else:
                        #raise forms.ValidationError('The username of your choice is unavailable. Please choose a different one.')
                
                except IntegrityError,e:
                    #raise signupform2.ValidationError('The username of your choice is unavailable. Please choose a different one.')
                    signupform2._errors["username"] = signupform2.error_class(["Oops!!! Cannot sign(you)up with this username. Please select a different one"])
开发者ID:cgosalia,项目名称:PasswordResetCode,代码行数:76,代码来源:views.py

示例15: print

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import save [as 别名]
    from members.models import Member, MemberType

    print("done.")

    #Do we have any member types
    total_types = len(MemberType.objects.all())
    if total_types == 0:
        print("No types found. Creating \"Member\".")
        mtype = MemberType(name="Member")
        mtype.save()
        print("done.")

    mtype = MemberType.objects.get(name__iexact="Member")
    
    total_mem = len(Member.objects.all())
    m1 = Member(number = total_mem+1,
                type = mtype,
                first_name = "Corey",
                last_name = "Clayton",
                birth_date = "1961-10-30",
                first_seen_date = datetime.date.today(),
                last_seen_date = datetime.date.today(),
                address = "206 Comber",
                city = "Dorval",
                postal_code = "H9S 2Y4",
                phone_number = "5142611046",
                email = "[email protected]",
                emergency_contact = "Meaghan Mueller",
                emergency_phone_number = "5146181390")
    m1.save()
开发者ID:C-o-r-E,项目名称:msys,代码行数:32,代码来源:create_test_members.py


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