class Donation(TimestampMixin): donor = models.ForeignKey(MyUser, on_delete=models.DO_NOTHING, null=True, default=None) program = models.ForeignKey(Program, on_delete=models.DO_NOTHING, null=False) beneficiaries = models.ManyToManyField(BeneficiaryAmount, related_name='beneficiaries', null=True) donation_amount = models.FloatField(null=True) certificate_amount = models.FloatField(null=True) donation_status = models.IntegerField(choices=DonationState.choices(), default=DonationState.PENDING.value, null=False) donation_anonymous_state = models.IntegerField( choices=DonorAnonymStatus.choices(), default=DonorAnonymStatus.PUBLIC.value, null=False) donation_type = models.IntegerField(choices=DonationType.choices(), default=DonationType.COMMON.value, null=False) guest = models.BooleanField(default=False) donation_automatic = models.BooleanField(default=False) class Meta: verbose_name = 'Donation' verbose_name_plural = 'Donations' def __str__(self): return 'donor {}, program {}, beneficiaries {}'.format( self.donor, self.program, self.beneficiaries)
class Beneficary(TimestampMixin): gender_status = models.IntegerField( choices=BeneficiariesGenderStatus.choices(), null=False) anonym_status = models.IntegerField( choices=BeneficiariesAnonymStatus.choices(), null=False) social_status = models.IntegerField( choices=BeneficiariesSocialStatus.choices(), null=False) # donation_state = models.IntegerField(choices=BeneficiariesDonationState.choices(), null=False) city = models.ForeignKey(City, null=True, blank=True, default=None, on_delete=models.DO_NOTHING) first_name = models.CharField(max_length=255, null=False) last_name = models.CharField(max_length=255, null=False) birthday = models.DateField(null=False) age = models.IntegerField(null=False, default=0) last_payment_day = models.DateTimeField(null=True, blank=True, default=None) payment_count = models.IntegerField(null=False, default=0) parents = models.TextField(null=True, blank=True, default=None) address = models.CharField(max_length=255, null=False) phone = models.CharField(max_length=255, null=False) characteristics = models.TextField(null=True, default=None) program = models.ForeignKey(Program, null=False, default=None, on_delete=models.DO_NOTHING) class Meta: verbose_name = 'Beneficary' verbose_name_plural = 'Beneficaries'
class Gift(TimestampMixin): partner_program = models.ForeignKey(PartnerProgram, null=True, on_delete=models.DO_NOTHING) beneficiary = models.ForeignKey(Beneficary, on_delete=models.DO_NOTHING) gift_counts = models.IntegerField(null=True) comment = models.TextField(null=False) gift_image = models.ImageField(upload_to='gift_images', null=True) class Meta: verbose_name = 'Gift' verbose_name_plural = 'Gifts'
class PartnerProgram(TimestampMixin): partner = models.ForeignKey(Partner, null=False, on_delete=models.DO_NOTHING, default=1) city = models.ForeignKey(City, null=False, on_delete=models.DO_NOTHING) title = models.CharField(max_length=255, null=False) description = models.TextField(null=False) class Meta: verbose_name = 'Partner program' verbose_name_plural = 'Partner programs'
class BeneficiaryAmount(TimestampMixin): beneficiary = models.ForeignKey(Beneficary, null=False, on_delete=models.DO_NOTHING) certificate_amount = models.FloatField(null=False) def __str__(self): return 'beneficiary: {}, certificate_amount: {}'.format( self.beneficiary, self.certificate_amount)
class Certificate(TimestampMixin): beneficiary = models.ForeignKey(Beneficary, on_delete=models.DO_NOTHING) program = models.CharField(max_length=255, null=True) amount = models.FloatField(null=True) partner_program = models.ForeignKey(PartnerProgram, on_delete=models.DO_NOTHING, null=True) donation = models.ForeignKey(Donation, on_delete=models.DO_NOTHING) issued_state = models.IntegerField(choices=IssueState.choices(), default=IssueState.CREATED.value) # issued_by = models.ForeignKey(MyUser, on_delete=models.DO_NOTHING) # donor_anonymous_status = models.IntegerField(choices=DonorAnonymStatus.choices(), # default=DonorAnonymStatus.PUBLIC.value) comment = models.TextField(null=True) # issue_date = models.DateField(auto_now_add=True) class Meta: verbose_name = 'Certificate' verbose_name_plural = 'Certificates'
class DonorRecurringProfile(TimestampMixin): donor = models.ForeignKey(MyUser, on_delete=models.DO_NOTHING) recurring_period = models.IntegerField( choices=DonorRecurringPeriod.choices(), null=False) recurring_profile_id = models.IntegerField(null=False) amount = models.IntegerField(null=False) recurring_period_expire_date = models.CharField(max_length=255, default=None) active_status = models.IntegerField(null=False) in_processing = models.IntegerField(default=None) last_transaction = models.TimeField(null=True, default=None) next_transaction = models.TimeField(null=True, default=None) class Meta: verbose_name = 'Donor recurring profile' verbose_name_plural = 'Donor recurring profiles'
class Migration(migrations.Migration): initial = True dependencies = [ ('utility', '0001_initial'), ('auth', '0011_update_proxy_permissions'), ] operations = [ migrations.CreateModel( name='MyUser', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('password', models.CharField(max_length=128, verbose_name='password')), ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Время создания')), ('updated_at', models.DateTimeField( auto_now=True, verbose_name='Время последнего изменения')), ('username', models.CharField(max_length=255, unique=True)), ('first_name', models.CharField(max_length=255, null=True)), ('second_name', models.CharField(max_length=255, null=True)), ('email', models.EmailField(max_length=254, unique=True)), ('role', models.IntegerField(choices=[(1, 'ADMIN'), (2, 'MANAGER'), (3, 'USER'), (4, 'MANAGER_REGION'), (5, 'PARTNER')], default=3)), ('is_active', models.BooleanField(default=True)), ('is_superuser', models.BooleanField(default=False)), ('is_staff', models.BooleanField(default=False)), ('join_date', models.DateTimeField(auto_now=True)), ('pay_zakyat', models.BooleanField(default=False)), ('city', models.ForeignKey( null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='utility.City')), ('groups', models.ManyToManyField( blank=True, help_text= 'The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), ('user_permissions', models.ManyToManyField( blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), ], options={ 'verbose_name': 'user', 'verbose_name_plural': 'users', }, managers=[ ('objects', app.users.models.MyUserManager()), ], ), migrations.CreateModel( name='PasswordResets', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Время создания')), ('updated_at', models.DateTimeField( auto_now=True, verbose_name='Время последнего изменения')), ('email', models.CharField(max_length=255)), ('code', models.CharField(max_length=255)), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Password reset', 'verbose_name_plural': 'Password resets', }, ), migrations.CreateModel( name='Partner', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Время создания')), ('updated_at', models.DateTimeField( auto_now=True, verbose_name='Время последнего изменения')), ('title', models.CharField(max_length=255)), ('description', models.CharField(max_length=255)), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Partner', 'verbose_name_plural': 'Partners', }, ), ]
class Migration(migrations.Migration): initial = True dependencies = [ ('auth', '0012_alter_user_first_name_max_length'), ] operations = [ migrations.CreateModel( name='User', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('password', models.CharField(max_length=128, verbose_name='password')), ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), ('is_superuser', models.BooleanField( default=False, help_text= 'Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), ('is_staff', models.BooleanField( default=False, help_text= 'Designates whether the user can log into this admin site.', verbose_name='staff status')), ('is_active', models.BooleanField( default=True, help_text= 'Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), ('email', models.EmailField(max_length=254, unique=True, verbose_name='email address')), ('code', models.UUIDField(default=uuid.uuid4)), ('role', models.CharField(choices=[('teacher', '老師'), ('student', '學生'), ('unknow', '不知名'), ('system', '系統管理者')], default='unknow', max_length=15)), ('groups', models.ManyToManyField( blank=True, help_text= 'The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), ('user_permissions', models.ManyToManyField( blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), ], options={ 'verbose_name': 'user', 'verbose_name_plural': 'users', 'abstract': False, }, managers=[ ('objects', app.users.models.UserManager()), ], ), migrations.CreateModel( name='CommonParticipant', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=255, verbose_name='會議名稱')), ('creator', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='common_participant_creators', to=settings.AUTH_USER_MODEL)), ('participant', models.ManyToManyField( related_name='common_participant_participants', to=settings.AUTH_USER_MODEL)), ], ), ]
class Migration(migrations.Migration): dependencies = [ ('users', '0001_initial'), ] operations = [ migrations.AlterModelOptions( name='user', options={ 'ordering': ['first_name', 'email'], 'verbose_name': 'User', 'verbose_name_plural': 'Users' }, ), migrations.AlterModelManagers( name='user', managers=[ ('objects', app.users.models.UserManager()), ], ), migrations.RemoveField( model_name='user', name='name', ), migrations.RemoveField( model_name='user', name='username', ), migrations.AddField( model_name='user', name='gender', field=models.CharField(choices=[('M', 'Male'), ('F', 'Female')], max_length=2, null=True, verbose_name='Gender'), ), migrations.AlterField( model_name='user', name='email', field=models.EmailField(blank=True, max_length=254, unique=True, verbose_name='Email'), ), migrations.AlterModelTable( name='user', table='users', ), migrations.CreateModel( name='BillingAddress', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('street_address', models.CharField(max_length=100)), ('apartment_address', models.CharField(max_length=100)), ('country', django_countries.fields.CountryField(max_length=2)), ('zip', models.CharField(max_length=100)), ('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)), ], ), ]