Create a new account
354920
def newaccount(ctx, accountname, account, password):
    
    pprint(
        ctx.peerplays.create_account(accountname, registrar=account, password=password)
    )
1025634
def create(klass, account, name):
        
        audience = klass(account)
        getattr(audience, '__create_audience__')(name)
        try:
            return audience.reload()
        except BadRequest as e:
            audience.delete()
            raise e
1213858
function createUser(ctx, next) {
            client.post({
                path: '/v1/users/'
            }, {
                username: opts.username,
                email: opts.email,
                password: opts.password
            }, function _afterCreateUser(err, req, res, body) {
                if (err && !res) {  // e.g. connect error
                    return next(err);
                }
                ctx.createStatusCode = res.statusCode;
                ctx.createErr = err;
                ctx.createBody = body;
                next();
            });
        }
1312535
function Account (client, opts) {
  var self = this
  if (!(self instanceof Account)) return new Account(client, opts)
  if (!opts) opts = {}

  self.client = client
}
1345824
def create_user(self, ):
        
        name = self.username_le.text()
        if not name:
            self.username_le.setPlaceholderText("Please provide a username.")
            return
        first = self.first_le.text()
        last = self.last_le.text()
        email = self.email_le.text()
        try:
            user = djadapter.models.User(username=name, first_name=first, last_name=last, email=email)
            user.save()
            for prj in self.projects:
                prj.users.add(user)
            for task in self.tasks:
                task.users.add(user)
            self.user = user
            self.accept()
        except:
            log.exception("Could not create new assettype")
862268
def save(self):
        
        username, email, password, first_name, last_name = (self.cleaned_data['username'],
                                     self.cleaned_data['email'],
                                     self.cleaned_data['password1'],
                                     self.cleaned_data['first_name'],
                                     self.cleaned_data['last_name'],)

        new_user = get_user_model()(username=username,
                                 email=email,
                                 first_name=first_name,
                                 last_name=last_name)
        new_user.set_password(password)
        new_user.save()
        return new_user
1004237
def create_new_course(self, account_id, course_allow_student_forum_attachments=None, course_allow_student_wiki_edits=None, course_allow_wiki_comments=None, course_apply_assignment_group_weights=None, course_course_code=None, course_course_format=None, course_end_at=None, course_grading_standard_id=None, course_hide_final_grades=None, course_integration_id=None, course_is_public=None, course_is_public_to_auth_users=None, course_license=None, course_name=None, course_open_enrollment=None, course_public_description=None, course_public_syllabus=None, course_public_syllabus_to_auth=None, course_restrict_enrollments_to_course_dates=None, course_self_enrollment=None, course_sis_course_id=None, course_start_at=None, course_syllabus_body=None, course_term_id=None, course_time_zone=None, enable_sis_reactivation=None, enroll_me=None, offer=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - account_id
        """ID"""
        path["account_id"] = account_id

        # OPTIONAL - course[name]
        """The name of the course. If omitted, the course will be named "Unnamed
        Course." """
        if course_name is not None:
            data["course[name]"] = course_name

        # OPTIONAL - course[course_code]
        """The course code for the course."""
        if course_course_code is not None:
            data["course[course_code]"] = course_course_code

        # OPTIONAL - course[start_at]
        """Course start date in ISO8601 format, e.g. 2011-01-01T01:00Z"""
        if course_start_at is not None:
            data["course[start_at]"] = course_start_at

        # OPTIONAL - course[end_at]
        """Course end date in ISO8601 format. e.g. 2011-01-01T01:00Z"""
        if course_end_at is not None:
            data["course[end_at]"] = course_end_at

        # OPTIONAL - course[license]
        """The name of the licensing. Should be one of the following abbreviations
        (a descriptive name is included in parenthesis for reference):
        - 'private' (Private Copyrighted)
        - 'cc_by_nc_nd' (CC Attribution Non-Commercial No Derivatives)
        - 'cc_by_nc_sa' (CC Attribution Non-Commercial Share Alike)
        - 'cc_by_nc' (CC Attribution Non-Commercial)
        - 'cc_by_nd' (CC Attribution No Derivatives)
        - 'cc_by_sa' (CC Attribution Share Alike)
        - 'cc_by' (CC Attribution)
        - 'public_domain' (Public Domain)."""
        if course_license is not None:
            data["course[license]"] = course_license

        # OPTIONAL - course[is_public]
        """Set to true if course is public to both authenticated and unauthenticated users."""
        if course_is_public is not None:
            data["course[is_public]"] = course_is_public

        # OPTIONAL - course[is_public_to_auth_users]
        """Set to true if course is public only to authenticated users."""
        if course_is_public_to_auth_users is not None:
            data["course[is_public_to_auth_users]"] = course_is_public_to_auth_users

        # OPTIONAL - course[public_syllabus]
        """Set to true to make the course syllabus public."""
        if course_public_syllabus is not None:
            data["course[public_syllabus]"] = course_public_syllabus

        # OPTIONAL - course[public_syllabus_to_auth]
        """Set to true to make the course syllabus public for authenticated users."""
        if course_public_syllabus_to_auth is not None:
            data["course[public_syllabus_to_auth]"] = course_public_syllabus_to_auth

        # OPTIONAL - course[public_description]
        """A publicly visible description of the course."""
        if course_public_description is not None:
            data["course[public_description]"] = course_public_description

        # OPTIONAL - course[allow_student_wiki_edits]
        """If true, students will be able to modify the course wiki."""
        if course_allow_student_wiki_edits is not None:
            data["course[allow_student_wiki_edits]"] = course_allow_student_wiki_edits

        # OPTIONAL - course[allow_wiki_comments]
        """If true, course members will be able to comment on wiki pages."""
        if course_allow_wiki_comments is not None:
            data["course[allow_wiki_comments]"] = course_allow_wiki_comments

        # OPTIONAL - course[allow_student_forum_attachments]
        """If true, students can attach files to forum posts."""
        if course_allow_student_forum_attachments is not None:
            data["course[allow_student_forum_attachments]"] = course_allow_student_forum_attachments

        # OPTIONAL - course[open_enrollment]
        """Set to true if the course is open enrollment."""
        if course_open_enrollment is not None:
            data["course[open_enrollment]"] = course_open_enrollment

        # OPTIONAL - course[self_enrollment]
        """Set to true if the course is self enrollment."""
        if course_self_enrollment is not None:
            data["course[self_enrollment]"] = course_self_enrollment

        # OPTIONAL - course[restrict_enrollments_to_course_dates]
        """Set to true to restrict user enrollments to the start and end dates of the
        course."""
        if course_restrict_enrollments_to_course_dates is not None:
            data["course[restrict_enrollments_to_course_dates]"] = course_restrict_enrollments_to_course_dates

        # OPTIONAL - course[term_id]
        """The unique ID of the term to create to course in."""
        if course_term_id is not None:
            data["course[term_id]"] = course_term_id

        # OPTIONAL - course[sis_course_id]
        """The unique SIS identifier."""
        if course_sis_course_id is not None:
            data["course[sis_course_id]"] = course_sis_course_id

        # OPTIONAL - course[integration_id]
        """The unique Integration identifier."""
        if course_integration_id is not None:
            data["course[integration_id]"] = course_integration_id

        # OPTIONAL - course[hide_final_grades]
        """If this option is set to true, the totals in student grades summary will
        be hidden."""
        if course_hide_final_grades is not None:
            data["course[hide_final_grades]"] = course_hide_final_grades

        # OPTIONAL - course[apply_assignment_group_weights]
        """Set to true to weight final grade based on assignment groups percentages."""
        if course_apply_assignment_group_weights is not None:
            data["course[apply_assignment_group_weights]"] = course_apply_assignment_group_weights

        # OPTIONAL - course[time_zone]
        """The time zone for the course. Allowed time zones are
        {http://www.iana.org/time-zones IANA time zones} or friendlier
        {http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html Ruby on Rails time zones}."""
        if course_time_zone is not None:
            data["course[time_zone]"] = course_time_zone

        # OPTIONAL - offer
        """If this option is set to true, the course will be available to students
        immediately."""
        if offer is not None:
            data["offer"] = offer

        # OPTIONAL - enroll_me
        """Set to true to enroll the current user as the teacher."""
        if enroll_me is not None:
            data["enroll_me"] = enroll_me

        # OPTIONAL - course[syllabus_body]
        """The syllabus body for the course"""
        if course_syllabus_body is not None:
            data["course[syllabus_body]"] = course_syllabus_body

        # OPTIONAL - course[grading_standard_id]
        """The grading standard id to set for the course.  If no value is provided for this argument the current grading_standard will be un-set from this course."""
        if course_grading_standard_id is not None:
            data["course[grading_standard_id]"] = course_grading_standard_id

        # OPTIONAL - course[course_format]
        """Optional. Specifies the format of the course. (Should be 'on_campus', 'online', or 'blended')"""
        if course_course_format is not None:
            data["course[course_format]"] = course_course_format

        # OPTIONAL - enable_sis_reactivation
        """When true, will first try to re-activate a deleted course with matching sis_course_id if possible."""
        if enable_sis_reactivation is not None:
            data["enable_sis_reactivation"] = enable_sis_reactivation

        self.logger.debug("POST /api/v1/accounts/{account_id}/courses with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("POST", "/api/v1/accounts/{account_id}/courses".format(**path), data=data, params=params, single_item=True)
1187351
async def create_account(self, **params):
		
		logging.debug("\n\n[+] -- Create account debugging. ")
		model = {
		"unique": ["email", "public_key"],
		"required": ("public_key",),
		"default": {"count":len(settings.AVAILABLE_COIN_ID), 
					"level":2, 
					"news_count":0, 
					"email":None},
		"optional": ("phone",)}

		message = json.loads(params.get("message", "{}"))
	
		data = {**message.get("message"), "public_key":message["public_key"]}

		# check if all required
		required = all([True if i in data.keys() else False for i in model["required"]])

		if not required:
			return {"error": 400,
					"reason":"Missed required fields"}

		# Unique constraint
		get_account = await self.collection.find_one({"public_key":data.get("public_key")})

		# Try get account with current public key
		if get_account:
			return {"error": 400,
					"reason": "Unique violation error"}

		# Reload data.
		row = {i:data[i] for i in data 
				if i in model["required"] or i in model["optional"]}
		row.update({i:model["default"][i] for i in model["default"]})
		if data.get("email"):
			row["email"] = data.get("email")
		row.update({"id":await self.autoincrement()})
		await self.collection.insert_one(row)
		account = await self.collection.find_one({"public_key":row["public_key"]})

		# Create wallets
		for coinid in coin_ids:
			database = client[coinid]
			wallet_collection = database[settings.WALLET]
			wallet = await wallet_collection.insert_one({
					"account_id": account["id"],
					"wallet": self.account.validator[coinid](account["public_key"]) 
				})
		return account
1092613
def newaccount(ctx, accountname, account, password):
    
    print_tx(
        ctx.bitshares.create_account(accountname, registrar=account, password=password)
    )
1241109
def adduser(app, username, password):
    """"""
    with app.app_context():
        create_user(username=username, password=password)
        click.echo('user created!')
453125
function createAccount (commandOptions, { accountName, domainId, publicKey }) {
  return command(
    commandOptions,
    txHelper.addCommand(
      txHelper.emptyTransaction(),
      'createAccount',
      {
        accountName,
        domainId,
        publicKey
      }
    )
  )
}
1111885
function create(req, res, next) {
  var body = req.body;
  body.user_id = req.session.user.id;

  db.posts.create(req.body, function(err, post) {
    if(err) { return next(err); }

    res.json(201, post);
    signals.emit('post:create', post);
  });
}
273086
def create_user(**data):
    """"""
    if 'username' not in data or 'password' not in data:
        raise ValueError('username and password are required.')

    # Hash the user password
    data['password'] = generate_password_hash(
        data.pop('password'),
        method='pbkdf2:sha256'
    )

    # Here you insert the `data` in your users database
    # for this simple example we are recording in a json file
    db_users = json.load(open('users.json'))
    # add the new created user to json
    db_users[data['username']] = data
    # commit changes to database
    json.dump(db_users, open('users.json', 'w'))
    return data
177488
def _create_user(self, email, password, **extra_fields):
        """"""
        if not email:
            raise ValueError("The given email must be set")
        email = self.normalize_email(email)
        user = self.model(email=email, **extra_fields)
        user.set_password(password)
        user.save(using=self._db)
        return user
497048
@RequestMapping(value = "create", method = RequestMethod.POST)
    public Account create(@RequestBody @Valid AccountInput input) {
        return accountService.create(input);
    }
158680
def new_account(
            self,
            account_cookie=None,
            init_cash=1000000,
            market_type=MARKET_TYPE.STOCK_CN,
            *args,
            **kwargs
    ):
        

        if account_cookie is None:
            """创建新的account

            Returns:
                [type] -- [description]
            """
            # 如果组合的cash_available>创建新的account所需cash
            if self.cash_available >= init_cash:

                temp = QA_Account(
                    user_cookie=self.user_cookie,
                    portfolio_cookie=self.portfolio_cookie,
                    init_cash=init_cash,
                    market_type=market_type,
                    *args,
                    **kwargs
                )
                if temp.account_cookie not in self.account_list:
                    #self.accounts[temp.account_cookie] = temp
                    self.account_list.append(temp.account_cookie)
                    temp.save()
                    self.cash.append(self.cash_available - init_cash)
                    return temp

                else:
                    return self.new_account()
        else:
            if self.cash_available >= init_cash:
                if account_cookie not in self.account_list:

                    acc = QA_Account(
                        portfolio_cookie=self.portfolio_cookie,
                        user_cookie=self.user_cookie,
                        init_cash=init_cash,
                        market_type=market_type,
                        account_cookie=account_cookie,
                        *args,
                        **kwargs
                    )
                    acc.save()
                    self.account_list.append(acc.account_cookie)
                    self.cash.append(self.cash_available - init_cash)
                    return acc
                else:
                    return self.get_account_by_cookie(account_cookie)
962730
def create_user(self, **kwargs):
        """"""
        roles = kwargs.pop('roles', [])
        user = self.user_model(**self._prepare_create_user_args(**kwargs))
        user = self.put(user)
        for role in roles:
            self.add_role_to_user(user, role)
        self.put(user)
        return user