This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager | |
from django.db import models | |
class AccountManager(BaseUserManager): | |
def create_user(self, username, password=None, **kwargs): | |
if not username: | |
raise ValueError('Users must have a valid username.') | |
if not kwargs.get('email'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AccountSerializer(serializers.ModelSerializer): | |
password = serializers.CharField(write_only=True, required=False) | |
confirm_password = serializers.CharField(write_only=True, required=False) | |
class Meta: | |
model = Account | |
fields = ('id', 'username', 'first_name', 'last_name', 'email', 'gender', 'avatar', | |
'is_admin', 'last_login', 'date_joined', 'password', 'confirm_password', 'updated_at') | |
def create(self, validated_data): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthenticationTest(TestCase): | |
def setUp(self): | |
self.client = APIClient(enforce_csrf_checks=True) | |
self.user_password = 'a12345678' | |
self.user_username = 'admin' | |
self.data = { | |
'username': self.user_username, | |
'password': self.user_password | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Output, EventEmitter, OnInit } from '@angular/core'; | |
import { FormGroup, FormBuilder } from '@angular/forms'; | |
@Component({ | |
selector: 'shipping-form', | |
templateUrl: './shipping.component.html', | |
styleUrls: [ './shipping.component.scss' ] | |
}) | |
export class ShippingFormComponent { | |
@Output() formReady = new EventEmitter<FormGroup>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="mat-typography"> | |
<h1>Checkout Order</h1> | |
<div class="checkout-form"> | |
<form novalidate [formGroup]="checkoutForm"> | |
<mat-form-field> | |
<input matInput type="text" placeholder='Full name' formControlName="fullName"> | |
</mat-form-field> | |
<mat-tab-group> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.usersForm = this.fb.group({ | |
userInput: null | |
}) | |
this.filteredUsers = this.usersForm | |
.get('userInput') | |
.valueChanges | |
.pipe( | |
debounceTime(300), | |
switchMap(value => this.appService.search({name: value}, 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn"> | |
<mat-option *ngFor="let user of (filteredUsers | async)?.results" [value]="user"> | |
<span>{{ user.name }}</span> | |
<small> | ID: {{user.id}}</small> | |
</mat-option> | |
</mat-autocomplete> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.usersForm = this.fb.group({ | |
userInput: null | |
}) | |
this.usersForm | |
.get('userInput') | |
.valueChanges | |
.pipe( | |
debounceTime(300), | |
tap(() => this.isLoading = true), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Output, EventEmitter, OnInit, AfterContentInit, Input, OnChanges, SimpleChanges } from '@angular/core'; | |
import { FormGroup, FormBuilder } from '@angular/forms'; | |
import { User } from '../users/user.class'; | |
@Component({ | |
selector: 'shipping-form', | |
templateUrl: './shipping.component.html', | |
styleUrls: [ './shipping.component.scss' ] | |
}) | |
export class ShippingFormComponent implements OnChanges, OnInit { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import {FormGroup, FormBuilder} from '@angular/forms'; | |
@Component({ | |
selector: 'my-app', | |
templateUrl: './app.component.html', | |
styleUrls: [ './app.component.scss' ] | |
}) | |
export class AppComponent implements OnInit { | |
checkoutForm: FormGroup; |
OlderNewer