# Generated by Django 4.2 on 2024-02-02 15:08

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='AccessTokens',
            fields=[
                ('uid', models.AutoField(editable=False, primary_key=True, serialize=False, unique=True, verbose_name='UID')),
                ('description', models.TextField(blank=True, help_text='Enter a brief description of the access token', null=True)),
                ('active', models.BooleanField(default=True, help_text='Is this access token active or not', verbose_name='Is Active')),
                ('token_user', models.CharField(help_text='User of this token', max_length=64, unique=True, verbose_name='Token User')),
                ('token_pass', models.CharField(help_text='Pass of this token', max_length=64, unique=True, verbose_name='Token Pass')),
                ('start_date', models.DateTimeField(default=django.utils.timezone.now, help_text='Date and time will be start this token', verbose_name='Start Date')),
                ('end_date', models.DateTimeField(default=django.utils.timezone.now, help_text='Date and time will be expired this token', verbose_name='End Date')),
                ('hourly_access', models.BooleanField(default=False, help_text='Is this token will be closed in specific times', verbose_name='Daily Access')),
                ('hourly_access_start', models.TimeField(blank=True, help_text='Start time of hourly access', null=True, verbose_name='Start Hourly Access')),
                ('hourly_access_end', models.TimeField(blank=True, help_text='End time of daily access', null=True, verbose_name='End Daily Access')),
                ('saturday', models.BooleanField(default=False, help_text='Is this token will be closed in Saturday', verbose_name='Saturday')),
                ('sunday', models.BooleanField(default=False, help_text='Is this token will be closed in Sunday', verbose_name='Sunday')),
                ('monday', models.BooleanField(default=False, help_text='Is this token will be closed in Monday', verbose_name='Monday')),
                ('tuesday', models.BooleanField(default=False, help_text='Is this token will be closed in Tuesday', verbose_name='Tuesday')),
                ('wednesday', models.BooleanField(default=False, help_text='Is this token will be closed in Wednesday', verbose_name='Wednesday')),
                ('thursday', models.BooleanField(default=False, help_text='Is this token will be closed in Thursday', verbose_name='Thursday')),
                ('friday', models.BooleanField(default=False, help_text='Is this token will be closed in Friday', verbose_name='Friday')),
                ('access_type', models.CharField(blank=True, choices=[('PIP_UPLOAD', 'PIP_UPLOAD'), ('PIP_DOWNLOAD', 'PIP_DOWNLOAD'), ('ALL', '*')], max_length=64, verbose_name='نوع المستخدمين')),
            ],
        ),
        migrations.CreateModel(
            name='Packages',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50)),
                ('description', models.TextField(blank=True, help_text='Enter a brief description of the package', null=True, verbose_name='Description')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('is_active', models.BooleanField(default=True)),
                ('allow4all', models.BooleanField(default=False, help_text='Allow all users to access this package', verbose_name='Allow All')),
                ('allow_md4all', models.BooleanField(default=False, verbose_name='Allow MD for all')),
                ('allow_md4', models.BooleanField(default=False, help_text='Allow MD for specific users and groups', verbose_name='Allow MD')),
            ],
            options={
                'verbose_name': 'Package',
                'verbose_name_plural': 'Packages',
                'ordering': ('-created_at',),
            },
        ),
        migrations.CreateModel(
            name='UserAccessToken',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uid', models.CharField(max_length=64, unique=True)),
                ('description', models.TextField(blank=True, help_text='Enter a brief description of the team', null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True, help_text='Date and time at which this team was created', verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, help_text='Date and time at which this team was last updated', verbose_name='Updated At')),
                ('is_active', models.BooleanField(default=True, help_text='Is this team active or not', verbose_name='Is Active')),
                ('access_tokens', models.ManyToManyField(help_text='Select the access tokens for this user', related_name='user_access_token', to='PPM.accesstokens', verbose_name='Access Tokens')),
                ('user', models.ForeignKey(help_text='Select the user who will can access this project', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='project_user', to=settings.AUTH_USER_MODEL, verbose_name='Project User')),
            ],
            options={
                'verbose_name': 'Team',
                'verbose_name_plural': 'Teams',
                'ordering': ('-created_at',),
            },
        ),
        migrations.CreateModel(
            name='Teams',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('tid', models.CharField(max_length=64, unique=True)),
                ('name', models.CharField(max_length=64)),
                ('description', models.TextField(blank=True, help_text='Enter a brief description of the team', null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True, help_text='Date and time at which this team was created', verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, help_text='Date and time at which this team was last updated', verbose_name='Updated At')),
                ('is_active', models.BooleanField(default=True, help_text='Is this team active or not', verbose_name='Is Active')),
                ('access_tokens', models.ManyToManyField(help_text='Select the access tokens for this team', related_name='team_access_token', to='PPM.accesstokens', verbose_name='Access Token')),
                ('manager', models.ForeignKey(help_text='Select the user who will be the manager of this team', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='team_manager', to=settings.AUTH_USER_MODEL, verbose_name='Team Manager')),
                ('members', models.ManyToManyField(blank=True, help_text='Select the users who will be the members of this team', related_name='project_team_members', to=settings.AUTH_USER_MODEL, verbose_name='Team Members')),
            ],
            options={
                'verbose_name': 'Team',
                'verbose_name_plural': 'Teams',
                'ordering': ('-created_at',),
            },
        ),
        migrations.CreateModel(
            name='Projects',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50)),
                ('description', models.TextField(blank=True, help_text='Enter a brief description of the project', null=True, verbose_name='Description of the project')),
                ('created_at', models.DateTimeField(auto_now_add=True, help_text='Date and time at which this project was created', verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, help_text='Date and time at which this project was last updated', verbose_name='Updated At')),
                ('is_active', models.BooleanField(default=True, help_text='Is this project active or not', verbose_name='Is Active')),
                ('manager', models.ForeignKey(help_text='Select the user who will be the manager of this project', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='project_manager', to=settings.AUTH_USER_MODEL, verbose_name='Project Manager')),
                ('packages', models.ForeignKey(help_text='Select the package for this team', on_delete=django.db.models.deletion.CASCADE, related_name='project_package', to='PPM.packages', verbose_name='Team Package')),
            ],
            options={
                'verbose_name': 'Project',
                'verbose_name_plural': 'Projects',
                'ordering': ('-created_at',),
            },
        ),
        migrations.CreateModel(
            name='PackageVersions',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('file', models.FileField(help_text='Upload the package file', upload_to='packages/', verbose_name='Package File')),
                ('version', models.CharField(help_text='Enter the version of the package', max_length=32, unique=True, verbose_name='Version')),
                ('description', models.TextField(blank=True, help_text='Enter a brief description of the package version', null=True, verbose_name='Description')),
                ('created_at', models.DateTimeField(auto_now_add=True, help_text='Date and time at which this package version was created', verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, help_text='Date and time at which this package version was last updated', verbose_name='Updated At')),
                ('shown_on_package', models.BooleanField(default=False, verbose_name='Shown on Packages')),
                ('user_uploaded', models.ForeignKey(help_text='Select the user who uploaded this package version', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='package_version_user_uploaded', to=settings.AUTH_USER_MODEL, verbose_name='User Uploaded')),
            ],
            options={
                'verbose_name': 'Package Version',
                'verbose_name_plural': 'Package Versions',
                'ordering': ('-created_at',),
                'unique_together': {('version', 'description')},
            },
        ),
        migrations.AddField(
            model_name='packages',
            name='versions',
            field=models.ManyToManyField(help_text='Select the versions for this package', related_name='package_version', to='PPM.packageversions', verbose_name='Package Versions'),
        ),
        migrations.CreateModel(
            name='AccessUsersLogs',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('alid', models.CharField(help_text='Unique ID for this access log', max_length=64, unique=True, verbose_name='Access Log ID')),
                ('accessed_at', models.DateTimeField(auto_now_add=True, help_text='Date and time at which this token was accessed', verbose_name='Accessed At')),
                ('accessed_from', models.GenericIPAddressField(help_text='IP Address of the user who accessed this token', verbose_name='Accessed From')),
                ('access_details', models.TextField(blank=True, help_text=' Details of the access', null=True)),
                ('access_token', models.ForeignKey(help_text='Token Accessed by this user', on_delete=django.db.models.deletion.CASCADE, related_name='access_token_accessed_by_user', to='PPM.accesstokens', verbose_name='Token Accessed')),
                ('package_version_accessed', models.ForeignKey(help_text='Package Version Accessed by this user', on_delete=django.db.models.deletion.CASCADE, related_name='user_log_package_version_accessed', to='PPM.packageversions', verbose_name='Package Version Accessed')),
                ('packages_accessed', models.ForeignKey(help_text='Packages Accessed by this user', on_delete=django.db.models.deletion.CASCADE, related_name='user_log_packages_accessed', to='PPM.packages', verbose_name='Packages Accessed')),
                ('project_accessed', models.ForeignKey(help_text='Project Accessed by this user', on_delete=django.db.models.deletion.CASCADE, related_name='user_log_project_accessed', to='PPM.projects', verbose_name='Project Accessed')),
                ('user', models.ForeignKey(help_text='User Accessed this token', on_delete=django.db.models.deletion.CASCADE, related_name='user_log_user_token_accessed', to=settings.AUTH_USER_MODEL, verbose_name='User Accessed')),
            ],
        ),
        migrations.AddField(
            model_name='accesstokens',
            name='packages',
            field=models.ForeignKey(help_text='Select the package for this team', on_delete=django.db.models.deletion.CASCADE, related_name='team_package', to='PPM.packages', verbose_name='Team Package'),
        ),
        migrations.AddField(
            model_name='accesstokens',
            name='projects',
            field=models.ForeignKey(help_text='Select the project for this team', on_delete=django.db.models.deletion.CASCADE, related_name='team_project', to='PPM.projects', verbose_name='Team Project'),
        ),
        migrations.CreateModel(
            name='AccessTeamsLogs',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('alid', models.CharField(help_text='Unique ID for this access log', max_length=64, unique=True, verbose_name='Access Log ID')),
                ('accessed_at', models.DateTimeField(auto_now_add=True, help_text='Date and time at which this token was accessed', verbose_name='Accessed At')),
                ('accessed_from', models.GenericIPAddressField(help_text='IP Address of the user who accessed this token', verbose_name='Accessed From')),
                ('access_details', models.TextField(blank=True, help_text=' Details of the access', null=True)),
                ('access_token', models.ForeignKey(help_text='Token Accessed by this user', on_delete=django.db.models.deletion.CASCADE, related_name='team_log_oken_accessed', to='PPM.accesstokens', verbose_name='Token Accessed')),
                ('package_version_accessed', models.ForeignKey(help_text='Package Version Accessed by this user', on_delete=django.db.models.deletion.CASCADE, related_name='team_log_package_version_accessed', to='PPM.packageversions', verbose_name='Package Version Accessed')),
                ('packages_accessed', models.ForeignKey(help_text='Packages Accessed by this user', on_delete=django.db.models.deletion.CASCADE, related_name='team_log_packages_accessed', to='PPM.packages', verbose_name='Packages Accessed')),
                ('project_accessed', models.ForeignKey(help_text='Project Accessed by this user', on_delete=django.db.models.deletion.CASCADE, related_name='team_log_project_accessed', to='PPM.projects', verbose_name='Project Accessed')),
                ('team', models.ForeignKey(help_text='User Accessed this token', on_delete=django.db.models.deletion.CASCADE, related_name='team_log_user_token_accessed', to=settings.AUTH_USER_MODEL, verbose_name='User Accessed')),
                ('user', models.ForeignKey(help_text='User Accessed this token', on_delete=django.db.models.deletion.CASCADE, related_name='team_log_user_accessed', to=settings.AUTH_USER_MODEL, verbose_name='User Accessed')),
            ],
        ),
        migrations.AlterUniqueTogether(
            name='packages',
            unique_together={('name', 'description')},
        ),
    ]
