Ejemplo n.º 1
0
class IconImage(models.Model):
    image = models.FileField(upload_to='icons')
    caption = models.CharField(max_length=45)
    source = models.CharField(max_length=100)
    def __str__(self):
	    return self.caption
Ejemplo n.º 2
0
class User(models.Model):
    """ Schema of user object. """

    email = models.EmailField(max_length=100, primary_key=True, db_index=True)
    name = models.CharField(max_length=60)
    password = models.CharField(max_length=255)
    roll_no = models.CharField(max_length=15, blank=True, null=True)
    date_of_birth = models.DateField()

    BRANCH_CHOICES = (
        ('CS', 'Computer Science and Engineering'),
        ('BME', 'Biomedical Engineering'),
        ('EC', 'Electronics & Communication Engineering'),
        ('EEE', 'Electrical Engineering'),
    )

    branch = models.CharField(max_length=3,
                              choices=BRANCH_CHOICES,
                              blank=True,
                              null=True)
    profilepic = models.FileField(default="", blank=True, null=True)

    def __str__(self):
        """ Generate an string representation of the object. """

        return '<{0} {1}>'.format(self.name, self.email)

    class Meta:
        """ Extra options for class User. """

        verbose_name_plural = 'Users'
        ordering = ['name']

    @classmethod
    def create(cls,
               email,
               name,
               password,
               dobday,
               dobmonth,
               dobyear,
               branch,
               roll_no=None):
        """ Create a user object.

        :param email: Email of the user.
        :param name: Name of the user.
        :param password: Password set by the user.
        :param dobday: Day of birth.
        :param dobmonth: Month of birth
        :param dobyear: Year of birth
        :param branch: Branch opted by the user (CS, EC, EEE, BME)
        :param roll_no: (default=None) optional field, specifying the roll no
                        of the user during his undergraduation.
        :return: An instance of User, or Error on failure.
        :rtype: class :User:
        """

        try:
            dob = self.generate_date(dobday, dobmonth, dobyear)

            user = cls(email=email,
                       name=name,
                       password=make_password(password),
                       roll_no=roll_no,
                       date_of_birth=dob,
                       branch=branch)

            user.save()

            return user

        except Exception as e:
            raise Exception("Error while creating user")

    @classmethod
    def login(cls, email, password):
        """ Authenticates the user.

        :param email: Email of the user.
        :param password: Password set by the user.

        :return: User object on successful login, false otherwise.
        :rtype: class :User:
        """

        try:
            user = cls.objects.get(email=email)

            if check_password(password, user.password):
                return user
            else:
                return False

        except Exception as e:
            raise Exception("Error while login")

    def generate_date(self, day, month, year):
        """ Return date object from string.
        
        :param day: Day of the date.
        :param month: Month of the date.
        :param year: Year of the date.

        :return: An instance of type date.
        :rtype: class :Date:
        """

        return datetime.date(year=year, month=month, day=day)
class Migration(migrations.Migration):

    dependencies = [
        ('app', '0002_auto_20160419_1751'),
    ]

    operations = [
        migrations.CreateModel(
            name='bolum',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('bolum', models.CharField(max_length=120)),
                ('updated', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='Cevaplar',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('baslik', models.CharField(max_length=120)),
                ('content', models.TextField()),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('aciklama', models.TextField()),
                ('ad_soyad', models.CharField(max_length=30)),
            ],
        ),
        migrations.CreateModel(
            name='Ders_Notlari',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('baslik', models.CharField(max_length=120)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('aciklama', models.TextField()),
                ('ad_soyad', models.CharField(max_length=30)),
                ('dosya', models.FileField(upload_to=b'')),
                ('bolum', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.bolum')),
            ],
        ),
        migrations.CreateModel(
            name='Ders_Videolari',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('baslik', models.CharField(max_length=120)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('aciklama', models.TextField()),
                ('ad_soyad', models.CharField(max_length=30)),
                ('dosya', models.FileField(upload_to=b'')),
                ('bolum', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.bolum')),
            ],
        ),
        migrations.CreateModel(
            name='Duyuru',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('baslik', models.CharField(max_length=120)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('aciklama', models.TextField()),
                ('bolum', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.bolum')),
            ],
        ),
        migrations.CreateModel(
            name='fakulte',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('fakulte', models.CharField(max_length=120)),
                ('updated', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='Gorusler',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('baslik', models.CharField(max_length=120)),
                ('content', models.TextField()),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('aciklama', models.TextField()),
                ('ad_soyad', models.CharField(max_length=30)),
            ],
        ),
        migrations.CreateModel(
            name='pay',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('ad_soyad', models.CharField(max_length=120)),
            ],
        ),
        migrations.CreateModel(
            name='Sikayet',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('baslik', models.CharField(max_length=120)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('sikayet_baslik', models.CharField(max_length=30)),
                ('aciklama', models.TextField()),
                ('ad_soyad', models.CharField(max_length=30)),
            ],
        ),
        migrations.CreateModel(
            name='Sorular',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('baslik', models.CharField(max_length=120)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('aciklama', models.TextField()),
                ('ad_soyad', models.CharField(max_length=30)),
                ('bolum', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.bolum')),
            ],
        ),
        migrations.CreateModel(
            name='Vize_Final',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('baslik', models.CharField(max_length=120)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('aciklama', models.TextField()),
                ('ad_soyad', models.CharField(max_length=30)),
                ('dosya', models.FileField(upload_to=b'')),
                ('bolum', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.bolum')),
                ('fakulte', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.fakulte')),
            ],
        ),
        migrations.DeleteModel(
            name='a1',
        ),
        migrations.AddField(
            model_name='duyuru',
            name='fakulte',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.fakulte'),
        ),
        migrations.AddField(
            model_name='ders_videolari',
            name='fakulte',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.fakulte'),
        ),
        migrations.AddField(
            model_name='ders_notlari',
            name='fakulte',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.fakulte'),
        ),
    ]
Ejemplo n.º 4
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Academician',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=50)),
                ('email', models.EmailField(max_length=254)),
            ],
        ),
        migrations.CreateModel(
            name='Student',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=30)),
                ('last_name', models.CharField(max_length=20)),
                ('email', models.EmailField(max_length=254)),
            ],
        ),
        migrations.CreateModel(
            name='StudentNotes',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=30)),
                ('pdf',
                 models.FileField(blank=True,
                                  null=True,
                                  upload_to='snotes/pdfs/')),
                ('image',
                 models.ImageField(blank=True,
                                   null=True,
                                   upload_to='snotes/images/')),
                ('student',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='library.student')),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='LectureNotes',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=30)),
                ('pdf',
                 models.FileField(blank=True,
                                  null=True,
                                  upload_to='lnotes/pdfs/')),
                ('image',
                 models.ImageField(blank=True,
                                   null=True,
                                   upload_to='lnotes/images/')),
                ('academician',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='library.academician')),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Course',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=50)),
                ('academician',
                 models.ForeignKey(
                     on_delete=django.db.models.deletion.RESTRICT,
                     to='library.academician')),
            ],
            options={
                'ordering': ['name'],
            },
        ),
    ]
Ejemplo n.º 5
0
class ArquivosQuestao(models.Model):
    numero_questao = models.IntegerField("NumeroQuestao")
    arquivo = models.FileField(upload_to="arquivosQ")
    questao = models.ForeignKey(Questao)
Ejemplo n.º 6
0
class Version(amo.models.OnChangeMixin, amo.models.ModelBase):
    addon = models.ForeignKey('addons.Addon', related_name='versions')
    license = models.ForeignKey('License', null=True)
    releasenotes = PurifiedField()
    approvalnotes = models.TextField(default='', null=True)
    version = models.CharField(max_length=255, default='0.1')
    version_int = models.BigIntegerField(null=True, editable=False)

    nomination = models.DateTimeField(null=True)
    reviewed = models.DateTimeField(null=True)

    has_info_request = models.BooleanField(default=False)
    has_editor_comment = models.BooleanField(default=False)

    deleted = models.BooleanField(default=False)

    supported_locales = models.CharField(max_length=255)

    _developer_name = models.CharField(max_length=255,
                                       default='',
                                       editable=False)

    source = models.FileField(upload_to=source_upload_path,
                              null=True,
                              blank=True)

    # The order of those managers is very important: please read the lengthy
    # comment above the Addon managers declaration/instanciation.
    unfiltered = VersionManager(include_deleted=True)
    objects = VersionManager()

    class Meta(amo.models.ModelBase.Meta):
        db_table = 'versions'
        ordering = ['-created', '-modified']

    def __init__(self, *args, **kwargs):
        super(Version, self).__init__(*args, **kwargs)
        self.__dict__.update(version_dict(self.version or ''))

    def __unicode__(self):
        return jinja2.escape(self.version)

    def save(self, *args, **kw):
        if not self.version_int and self.version:
            v_int = version_int(self.version)
            # Magic number warning, this is the maximum size
            # of a big int in MySQL to prevent version_int overflow, for
            # people who have rather crazy version numbers.
            # http://dev.mysql.com/doc/refman/5.5/en/numeric-types.html
            if v_int < 9223372036854775807:
                self.version_int = v_int
            else:
                log.error('No version_int written for version %s, %s' %
                          (self.pk, self.version))
        super(Version, self).save(*args, **kw)
        return self

    @classmethod
    def from_upload(cls,
                    upload,
                    addon,
                    platforms,
                    send_signal=True,
                    source=None,
                    is_beta=False):
        data = utils.parse_addon(upload, addon)
        try:
            license = addon.versions.latest().license_id
        except Version.DoesNotExist:
            license = None
        max_len = cls._meta.get_field_by_name('_developer_name')[0].max_length
        developer = data.get('developer_name', '')[:max_len]
        v = cls.objects.create(addon=addon,
                               version=data['version'],
                               license_id=license,
                               _developer_name=developer,
                               source=source)
        log.info('New version: %r (%s) from %r' % (v, v.id, upload))

        AV = ApplicationsVersions
        for app in data.get('apps', []):
            AV(version=v, min=app.min, max=app.max, application=app.id).save()
        if addon.type == amo.ADDON_SEARCH:
            # Search extensions are always for all platforms.
            platforms = [amo.PLATFORM_ALL.id]
        else:
            platforms = cls._make_safe_platform_files(platforms)

        for platform in platforms:
            File.from_upload(upload,
                             v,
                             platform,
                             parse_data=data,
                             is_beta=is_beta)

        v.disable_old_files()
        # After the upload has been copied to all platforms, remove the upload.
        storage.delete(upload.path)
        if send_signal:
            version_uploaded.send(sender=v)

        return v

    @classmethod
    def _make_safe_platform_files(cls, platforms):
        """Make file platform translations until all download pages
        support desktop ALL + mobile ALL. See bug 646268.

        Returns platforms ids.
        """
        pl_set = set(platforms)

        if pl_set == set((amo.PLATFORM_ALL.id, )):
            # Make it really ALL:
            return [amo.PLATFORM_ALL.id]

        has_mobile = amo.PLATFORM_ANDROID in pl_set
        has_desktop = any(p in amo.DESKTOP_PLATFORMS for p in pl_set)
        has_all = amo.PLATFORM_ALL in pl_set
        is_mixed = has_mobile and has_desktop
        if (is_mixed and has_all) or has_mobile:
            # Mixing desktop and mobile w/ ALL is not safe;
            # we have to split the files into exact platforms.
            new_plats = []
            for platform in platforms:
                if platform == amo.PLATFORM_ALL.id:
                    plats = amo.DESKTOP_PLATFORMS.keys()
                    plats.remove(amo.PLATFORM_ALL.id)
                    new_plats.extend(plats)
                else:
                    new_plats.append(platform)
            return new_plats

        # Platforms are safe as is
        return platforms

    @property
    def path_prefix(self):
        return os.path.join(user_media_path('addons'), str(self.addon_id))

    @property
    def mirror_path_prefix(self):
        return os.path.join(user_media_path('addons'), str(self.addon_id))

    def license_url(self, impala=False):
        return reverse('addons.license', args=[self.addon.slug, self.version])

    def flush_urls(self):
        return self.addon.flush_urls()

    def get_url_path(self):
        if not self.addon.is_listed:  # Not listed? Doesn't have a public page.
            return ''
        return reverse('addons.versions', args=[self.addon.slug, self.version])

    def delete(self):
        log.info(u'Version deleted: %r (%s)' % (self, self.id))
        amo.log(amo.LOG.DELETE_VERSION, self.addon, str(self.version))
        super(Version, self).delete()

    @property
    def current_queue(self):
        """Return the current queue, or None if not in a queue."""
        from editors.models import (ViewFullReviewQueue, ViewPendingQueue,
                                    ViewPreliminaryQueue,
                                    ViewUnlistedFullReviewQueue,
                                    ViewUnlistedPendingQueue,
                                    ViewUnlistedPreliminaryQueue)

        if self.addon.status in [
                amo.STATUS_NOMINATED, amo.STATUS_LITE_AND_NOMINATED
        ]:
            return (ViewFullReviewQueue
                    if self.addon.is_listed else ViewUnlistedFullReviewQueue)
        elif self.addon.status == amo.STATUS_PUBLIC:
            return (ViewPendingQueue
                    if self.addon.is_listed else ViewUnlistedPendingQueue)
        elif self.addon.status in [amo.STATUS_LITE, amo.STATUS_UNREVIEWED]:
            return (ViewPreliminaryQueue
                    if self.addon.is_listed else ViewUnlistedPreliminaryQueue)

        return None

    @amo.cached_property(writable=True)
    def all_activity(self):
        from devhub.models import VersionLog  # yucky
        al = (VersionLog.objects.filter(
            version=self.id).order_by('created').select_related(
                'activity_log', 'version').no_cache())
        return al

    @amo.cached_property(writable=True)
    def compatible_apps(self):
        """Get a mapping of {APP: ApplicationVersion}."""
        avs = self.apps.select_related('versions', 'license')
        return self._compat_map(avs)

    @amo.cached_property
    def compatible_apps_ordered(self):
        apps = self.compatible_apps.items()
        return sorted(apps, key=lambda v: v[0].short)

    def compatible_platforms(self):
        """Returns a dict of compatible file platforms for this version.

        The result is based on which app(s) the version targets.
        """
        app_ids = [a.application for a in self.apps.all()]
        targets_mobile = amo.ANDROID.id in app_ids
        targets_other = any((id_ != amo.ANDROID.id) for id_ in app_ids)
        all_plats = {}
        if targets_other:
            all_plats.update(amo.DESKTOP_PLATFORMS)
        if targets_mobile:
            all_plats.update(amo.MOBILE_PLATFORMS)
        return all_plats

    @amo.cached_property
    def is_compatible(self):
        """Returns tuple of compatibility and reasons why if not.

        Server side conditions for determining compatibility are:
            * The add-on is an extension (not a theme, app, etc.)
            * Has not opted in to strict compatibility.
            * Does not use binary_components in chrome.manifest.

        Note: The lowest maxVersion compat check needs to be checked
              separately.
        Note: This does not take into account the client conditions.
        """
        compat = True
        reasons = []
        if self.addon.type != amo.ADDON_EXTENSION:
            compat = False
            # TODO: We may want this. For now we think it may be confusing.
            # reasons.append(_('Add-on is not an extension.'))
        if self.files.filter(binary_components=True).exists():
            compat = False
            reasons.append(_('Add-on uses binary components.'))
        if self.files.filter(strict_compatibility=True).exists():
            compat = False
            reasons.append(
                _('Add-on has opted into strict compatibility '
                  'checking.'))
        return (compat, reasons)

    def is_compatible_app(self, app):
        """Returns True if the provided app passes compatibility conditions."""
        appversion = self.compatible_apps.get(app)
        if appversion and app.id in amo.D2C_MAX_VERSIONS:
            return (version_int(appversion.max.version) >= version_int(
                amo.D2C_MAX_VERSIONS.get(app.id, '*')))
        return False

    def compat_override_app_versions(self):
        """Returns the incompatible app versions range(s).

        If not ranges, returns empty list.  Otherwise, this will return all
        the app version ranges that this particular version is incompatible
        with.
        """
        from addons.models import CompatOverride
        cos = CompatOverride.objects.filter(addon=self.addon)
        if not cos:
            return []
        app_versions = []
        for co in cos:
            for range in co.collapsed_ranges():
                if (version_int(range.min) <= version_int(self.version) <=
                        version_int(range.max)):
                    app_versions.extend([(a.min, a.max) for a in range.apps])
        return app_versions

    @amo.cached_property(writable=True)
    def all_files(self):
        """Shortcut for list(self.files.all()).  Heavily cached."""
        return list(self.files.all())

    @amo.cached_property
    def supported_platforms(self):
        """Get a list of supported platform names."""
        return list(set(amo.PLATFORMS[f.platform] for f in self.all_files))

    @property
    def status(self):
        return [f.STATUS_CHOICES[f.status] for f in self.all_files]

    @property
    def statuses(self):
        """Unadulterated statuses, good for an API."""
        return [(f.id, f.status) for f in self.all_files]

    def is_allowed_upload(self):
        """
        Check that a file can be uploaded based on the files
        per platform for that type of addon.
        """
        num_files = len(self.all_files)
        if self.addon.type == amo.ADDON_SEARCH:
            return num_files == 0
        elif num_files == 0:
            return True
        elif amo.PLATFORM_ALL in self.supported_platforms:
            return False
        else:
            compatible = (v for k, v in self.compatible_platforms().items()
                          if k != amo.PLATFORM_ALL.id)
            return bool(set(compatible) - set(self.supported_platforms))

    def is_public(self):
        # To be public, a version must not be deleted, must belong to a public
        # addon, and all its attached files must have public status.
        try:
            return (not self.deleted and self.addon.is_public()
                    and all(f.status == amo.STATUS_PUBLIC
                            for f in self.all_files))
        except ObjectDoesNotExist:
            return False

    @property
    def has_files(self):
        return bool(self.all_files)

    @property
    def is_unreviewed(self):
        return filter(lambda f: f.status in amo.UNREVIEWED_STATUSES,
                      self.all_files)

    @property
    def is_all_unreviewed(self):
        return not bool([
            f
            for f in self.all_files if f.status not in amo.UNREVIEWED_STATUSES
        ])

    @property
    def is_beta(self):
        return filter(lambda f: f.status == amo.STATUS_BETA, self.all_files)

    @property
    def is_lite(self):
        return filter(lambda f: f.status in amo.LITE_STATUSES, self.all_files)

    @property
    def is_jetpack(self):
        return all(f.jetpack_version for f in self.all_files)

    @classmethod
    def _compat_map(cls, avs):
        apps = {}
        for av in avs:
            app_id = av.application
            if app_id in amo.APP_IDS:
                apps[amo.APP_IDS[app_id]] = av
        return apps

    @classmethod
    def transformer(cls, versions):
        """Attach all the compatible apps and files to the versions."""
        ids = set(v.id for v in versions)
        if not versions:
            return

        # FIXME: find out why we have no_cache() here and try to remove it.
        avs = (ApplicationsVersions.objects.filter(
            version__in=ids).select_related('application', 'apps', 'min_set',
                                            'max_set').no_cache())
        files = File.objects.filter(version__in=ids).no_cache()

        def rollup(xs):
            groups = amo.utils.sorted_groupby(xs, 'version_id')
            return dict((k, list(vs)) for k, vs in groups)

        av_dict, file_dict = rollup(avs), rollup(files)

        for version in versions:
            v_id = version.id
            version.compatible_apps = cls._compat_map(av_dict.get(v_id, []))
            version.all_files = file_dict.get(v_id, [])
            for f in version.all_files:
                f.version = version

    @classmethod
    def transformer_activity(cls, versions):
        """Attach all the activity to the versions."""
        from devhub.models import VersionLog  # yucky

        ids = set(v.id for v in versions)
        if not versions:
            return

        al = (VersionLog.objects.filter(
            version__in=ids).order_by('created').select_related(
                'activity_log', 'version').no_cache())

        def rollup(xs):
            groups = amo.utils.sorted_groupby(xs, 'version_id')
            return dict((k, list(vs)) for k, vs in groups)

        al_dict = rollup(al)

        for version in versions:
            v_id = version.id
            version.all_activity = al_dict.get(v_id, [])

    def disable_old_files(self):
        if not self.files.filter(status=amo.STATUS_BETA).exists():
            qs = File.objects.filter(
                version__addon=self.addon_id,
                version__lt=self.id,
                version__deleted=False,
                status__in=[amo.STATUS_UNREVIEWED, amo.STATUS_PENDING])
            # Use File.update so signals are triggered.
            for f in qs:
                f.update(status=amo.STATUS_DISABLED)

    @property
    def developer_name(self):
        return self._developer_name

    def reset_nomination_time(self, nomination=None):
        if not self.nomination or nomination:
            nomination = nomination or datetime.datetime.now()
            # We need signal=False not to call update_status (which calls us).
            self.update(nomination=nomination, _signal=False)
            # But we need the cache to be flushed.
            Version.objects.invalidate(self)

    @property
    def is_listed(self):
        return self.addon.is_listed

    @property
    def unreviewed_files(self):
        """A File is unreviewed if:
        - its status is in amo.UNDER_REVIEW_STATUSES or
        - its addon status is in amo.UNDER_REVIEW_STATUSES
          and its status is either in amo.UNDER_REVIEW_STATUSES or
          amo.STATUS_LITE
        """
        under_review_or_lite = amo.UNDER_REVIEW_STATUSES + (amo.STATUS_LITE, )
        return self.files.filter(
            models.Q(status__in=amo.UNDER_REVIEW_STATUSES)
            | models.Q(version__addon__status__in=amo.UNDER_REVIEW_STATUSES,
                       status__in=under_review_or_lite))
Ejemplo n.º 7
0
class File(ItemBase):
    file = models.FileField(upload_to='files')
Ejemplo n.º 8
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="File",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "image_file",
                    imagefield.fields.ImageField(
                        blank=True,
                        height_field="image_height",
                        upload_to="cabinet/%Y/%m",
                        verbose_name="image",
                        width_field="image_width",
                    ),
                ),
                (
                    "image_width",
                    models.PositiveIntegerField(
                        blank=True,
                        editable=False,
                        null=True,
                        verbose_name="image width",
                    ),
                ),
                (
                    "image_height",
                    models.PositiveIntegerField(
                        blank=True,
                        editable=False,
                        null=True,
                        verbose_name="image height",
                    ),
                ),
                (
                    "image_ppoi",
                    imagefield.fields.PPOIField(
                        default="0.5x0.5",
                        max_length=20,
                        verbose_name="primary point of interest",
                    ),
                ),
                (
                    "download_file",
                    models.FileField(
                        blank=True, upload_to="cabinet/%Y/%m", verbose_name="download"
                    ),
                ),
                (
                    "download_type",
                    models.CharField(
                        editable=False, max_length=20, verbose_name="download type"
                    ),
                ),
                (
                    "file_name",
                    models.CharField(max_length=1000, verbose_name="file name"),
                ),
                ("file_size", models.PositiveIntegerField(verbose_name="file size")),
            ],
            options={
                "abstract": False,
                "verbose_name": "file",
                "verbose_name_plural": "files",
                "ordering": ["file_name"],
                "swappable": "CABINET_FILE_MODEL",
            },
        ),
        migrations.CreateModel(
            name="Folder",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100, verbose_name="name")),
                (
                    "parent",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="children",
                        to="cabinet.Folder",
                        verbose_name="parent",
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "verbose_name": "folder",
                "verbose_name_plural": "folders",
            },
        ),
        migrations.AddField(
            model_name="file",
            name="folder",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT,
                related_name="files",
                to="cabinet.Folder",
                verbose_name="folder",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="folder", unique_together=set([("parent", "name")])
        ),
    ]
Ejemplo n.º 9
0
class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("server", "0009_auto_20201124_1718"),
    ]

    operations = [
        migrations.RemoveField(
            model_name="server",
            name="ssh_key_pass",
        ),
        migrations.CreateModel(
            name="ConnectionKeys",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=250)),
                (
                    "key",
                    models.FileField(
                        blank=True,
                        null=True,
                        upload_to=server.models.user_ssh_keys_path,
                    ),
                ),
                ("key_pass", models.CharField(blank=True, max_length=250, null=True)),
                (
                    "key_type",
                    models.CharField(
                        choices=[("SSH", "SSH"), ("SSL", "SSL")], max_length=5
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        editable=False,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
        ),
        migrations.RemoveField(
            model_name="database",
            name="ssl_key",
        ),
        migrations.RemoveField(
            model_name="server",
            name="ssh_key",
        ),
        migrations.AddField(
            model_name="database",
            name="ssl_key",
            field=models.ForeignKey(
                default=None,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to="server.connectionkeys",
            ),
        ),
        migrations.AddField(
            model_name="server",
            name="ssh_key",
            field=models.ForeignKey(
                default=None,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to="server.connectionkeys",
            ),
        ),
    ]
Ejemplo n.º 10
0
class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('exercises', '0002_auto_20200511_0132'),
    ]

    operations = [
        migrations.AlterField(
            model_name='submission',
            name='exercise',
            field=models.ForeignKey(
                editable=False,
                on_delete=django.db.models.deletion.PROTECT,
                to='exercises.Exercise'),
        ),
        migrations.AlterField(
            model_name='submission',
            name='file',
            field=models.FileField(
                upload_to=exercises.helper.get_submission_path,
                validators=[
                    exercises.validators.FileValidator(
                        allowed_extensions=['py'],
                        allowed_mimetypes=['text/x-python', 'text/plain'],
                        max_size=4000,
                        min_size=30)
                ]),
        ),
        migrations.AlterField(
            model_name='submission',
            name='user',
            field=models.ForeignKey(
                editable=False,
                on_delete=django.db.models.deletion.PROTECT,
                to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterField(
            model_name='testmessage',
            name='kind',
            field=models.CharField(choices=[('error', 'Error'),
                                            ('failure', 'Failure')],
                                   editable=False,
                                   max_length=8),
        ),
        migrations.AlterField(
            model_name='testmessage',
            name='message',
            field=models.TextField(default=None, editable=False),
        ),
        migrations.AlterField(
            model_name='testmessage',
            name='test',
            field=models.ForeignKey(
                editable=False,
                on_delete=django.db.models.deletion.CASCADE,
                to='exercises.TestResult'),
        ),
        migrations.AlterField(
            model_name='testresult',
            name='job_id',
            field=models.CharField(editable=False, max_length=128),
        ),
        migrations.AlterField(
            model_name='testresult',
            name='submission',
            field=models.OneToOneField(
                editable=False,
                on_delete=django.db.models.deletion.CASCADE,
                to='exercises.Submission'),
        ),
        migrations.AlterField(
            model_name='testresult',
            name='success_count',
            field=models.IntegerField(editable=False),
        ),
        migrations.AlterField(
            model_name='testresult',
            name='test_count',
            field=models.IntegerField(editable=False),
        ),
    ]
Ejemplo n.º 11
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('organization', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Course',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('add_time',
                 models.DateTimeField(default=datetime.datetime.now,
                                      verbose_name='添加时间')),
                ('name', models.CharField(max_length=50, verbose_name='课程名')),
                ('desc', models.CharField(max_length=300,
                                          verbose_name='课程描述')),
                ('learn_times',
                 models.IntegerField(default=0, verbose_name='学习时长(分钟数)')),
                ('degree',
                 models.CharField(choices=[('cj', '初级'), ('zj', '中级'),
                                           ('gj', '高级')],
                                  max_length=2,
                                  verbose_name='难度')),
                ('students', models.IntegerField(default=0,
                                                 verbose_name='学习人数')),
                ('fav_nums', models.IntegerField(default=0,
                                                 verbose_name='收藏人数')),
                ('click_nums',
                 models.IntegerField(default=0, verbose_name='点击数')),
                ('notice',
                 models.CharField(default='',
                                  max_length=300,
                                  verbose_name='课程公告')),
                ('category',
                 models.CharField(default='后端开发',
                                  max_length=20,
                                  verbose_name='课程类别')),
                ('tag',
                 models.CharField(default='',
                                  max_length=10,
                                  verbose_name='课程标签')),
                ('youneed_know',
                 models.CharField(default='',
                                  max_length=300,
                                  verbose_name='课程须知')),
                ('teacher_tell',
                 models.CharField(default='',
                                  max_length=300,
                                  verbose_name='老师告诉你')),
                ('is_classics',
                 models.BooleanField(default=False, verbose_name='是否经典')),
                ('detail', models.CharField(max_length=500,
                                            verbose_name='课程详情')),
                ('is_banner',
                 models.BooleanField(default=False, verbose_name='是否广告位')),
                ('image',
                 models.ImageField(upload_to='courses/%Y/%m',
                                   verbose_name='封面图')),
                ('course_org',
                 models.ForeignKey(blank=True,
                                   null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='organization.CourseOrg',
                                   verbose_name='课程机构')),
                ('teacher',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='organization.Teacher',
                                   verbose_name='讲师')),
            ],
            options={
                'verbose_name': '课程信息',
                'verbose_name_plural': '课程信息',
            },
        ),
        migrations.CreateModel(
            name='Lesson',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('add_time',
                 models.DateTimeField(default=datetime.datetime.now,
                                      verbose_name='添加时间')),
                ('name', models.CharField(max_length=100, verbose_name='章节名')),
                ('learn_times',
                 models.IntegerField(default=0, verbose_name='学习时长(分钟数)')),
                ('course',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='courses.Course',
                                   verbose_name='课程')),
            ],
            options={
                'verbose_name': '课程章节',
                'verbose_name_plural': '课程章节',
            },
        ),
        migrations.CreateModel(
            name='Video',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('add_time',
                 models.DateTimeField(default=datetime.datetime.now,
                                      verbose_name='添加时间')),
                ('name', models.CharField(max_length=100, verbose_name='视频名')),
                ('learn_times',
                 models.IntegerField(default=0, verbose_name='学习时长(分钟数)')),
                ('url', models.CharField(max_length=1000,
                                         verbose_name='访问地址')),
                ('lesson',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='courses.Lesson',
                                   verbose_name='章节')),
            ],
            options={
                'verbose_name': '视频',
                'verbose_name_plural': '视频',
            },
        ),
        migrations.CreateModel(
            name='CourseTag',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('add_time',
                 models.DateTimeField(default=datetime.datetime.now,
                                      verbose_name='添加时间')),
                ('tag', models.CharField(max_length=100, verbose_name='标签')),
                ('course',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='courses.Course',
                                   verbose_name='课程')),
            ],
            options={
                'verbose_name': '课程标签',
                'verbose_name_plural': '课程标签',
            },
        ),
        migrations.CreateModel(
            name='CourseResource',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('add_time',
                 models.DateTimeField(default=datetime.datetime.now,
                                      verbose_name='添加时间')),
                ('name', models.CharField(max_length=100, verbose_name='名称')),
                ('file',
                 models.FileField(max_length=200,
                                  upload_to='course/resourse/%Y/%m',
                                  verbose_name='下载地址')),
                ('course',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='courses.Course',
                                   verbose_name='课程')),
            ],
            options={
                'verbose_name': '课程资源',
                'verbose_name_plural': '课程资源',
            },
        ),
        migrations.CreateModel(
            name='BannerCourse',
            fields=[],
            options={
                'verbose_name': '轮播课程',
                'verbose_name_plural': '轮播课程',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('courses.course', ),
        ),
    ]
Ejemplo n.º 12
0
class Sponsor(ContentManageable):
    name = models.CharField(
        max_length=100,
        verbose_name="Sponsor name",
        help_text="Name of the sponsor, for public display.",
    )
    description = models.TextField(
        verbose_name="Sponsor description",
        help_text="Brief description of the sponsor for public display.",
    )
    landing_page_url = models.URLField(
        blank=True,
        null=True,
        verbose_name="Sponsor landing page",
        help_text=
        "Sponsor landing page URL. This may be provided by the sponsor, however the linked page may not contain any sales or marketing information.",
    )
    twitter_handle = models.CharField(
        max_length=
        32,  # Actual limit set by twitter is 15 characters, but that may change?
        blank=True,
        null=True,
        verbose_name="Sponsor twitter hanlde",
    )
    web_logo = models.ImageField(
        upload_to="sponsor_web_logos",
        verbose_name="Sponsor web logo",
        help_text=
        "For display on our sponsor webpage. High resolution PNG or JPG, smallest dimension no less than 256px",
    )
    print_logo = models.FileField(
        upload_to="sponsor_print_logos",
        blank=True,
        null=True,
        verbose_name="Sponsor print logo",
        help_text="For printed materials, signage, and projection. SVG or EPS",
    )

    primary_phone = models.CharField("Sponsor Primary Phone", max_length=32)
    mailing_address_line_1 = models.CharField(
        verbose_name="Mailing Address line 1", max_length=128, default="")
    mailing_address_line_2 = models.CharField(
        verbose_name="Mailing Address line 2",
        max_length=128,
        blank=True,
        default="")
    city = models.CharField(verbose_name="City", max_length=64, default="")
    state = models.CharField(verbose_name="State/Province/Region",
                             max_length=64,
                             blank=True,
                             default="")
    postal_code = models.CharField(verbose_name="Zip/Postal Code",
                                   max_length=64,
                                   default="")
    country = CountryField(default="")

    class Meta:
        verbose_name = "sponsor"
        verbose_name_plural = "sponsors"

    def verified_emails(self, initial_emails=None):
        emails = initial_emails if initial_emails is not None else []
        for contact in self.contacts.all():
            if EmailAddress.objects.filter(email__iexact=contact.email,
                                           verified=True).exists():
                emails.append(contact.email)
        return list(set({e.casefold(): e for e in emails}.values()))

    def __str__(self):
        return f"{self.name}"
Ejemplo n.º 13
0
class Video(TimestampMixin, Stageable, Sortable, Deletable, models.Model):
    course = models.ForeignKey(Course, db_index=True)
    section = models.ForeignKey(ContentSection, null=True, db_index=True)
    title = models.CharField(max_length=255, null=True, blank=True)
    description = models.TextField(blank=True)
    type = models.CharField(max_length=30, default="youtube")
    url = models.CharField("Youtube Video ID", max_length=255, null=True, blank=True)
    duration = models.IntegerField(null=True)
    slug = models.SlugField("URL Identifier", max_length=255, null=True)
    file = models.FileField(upload_to=get_file_path)
    handle = models.CharField(max_length=255, null=True, db_index=True)
#    kelvinator = models.IntegerField("K-Threshold", default=15)
    objects = VideoManager()

    def create_ready_instance(self):
        ready_instance = Video(
            course=self.course.image,
            section=self.section.image,
            title=self.title,
            description=self.description,
            type=self.type,
            url=self.url,
            duration=self.duration,
            slug=self.slug,
            file=self.file,
            image = self,
            index = self.index,
            mode = 'ready',
            handle = self.handle,
            live_datetime = self.live_datetime,
        )
        ready_instance.save()
        self.image = ready_instance
        self.save()

    def exercises_changed(self):
        ready_instance = self.image
        draft_videoToExs = VideoToExercise.objects.getByVideo(self)
        ready_videoToExs = VideoToExercise.objects.getByVideo(ready_instance)
        if len(draft_videoToExs) != len(ready_videoToExs):
            return True
        for draft_videoToEx in draft_videoToExs:
            if not draft_videoToEx.image:
                return True
        return False

    def commit(self, clone_fields = None):
        if self.mode != 'draft': return;
        if not self.image: self.create_ready_instance()

        ready_instance = self.image
        if not clone_fields or 'title' in clone_fields:
            ready_instance.title = self.title
        if not clone_fields or 'section' in clone_fields:
            ready_instance.section = self.section.image
        if not clone_fields or 'description' in clone_fields:
            ready_instance.description = self.description
        if not clone_fields or 'slug' in clone_fields:
            ready_instance.slug = self.slug
        if not clone_fields or 'file' in clone_fields:
            ready_instance.file = self.file
        if not clone_fields or 'url' in clone_fields:
            ready_instance.url = self.url
        if not clone_fields or 'live_datetime' in clone_fields:
            ready_instance.live_datetime = self.live_datetime

        ready_instance.save()

        if self.exercises_changed() == True:
            draft_videoToExs =  VideoToExercise.objects.getByVideo(self)
            ready_videoToExs = VideoToExercise.objects.getByVideo(ready_instance)
            #Delete all previous relationships
            for ready_videoToEx in ready_videoToExs:
                ready_videoToEx.delete()
                ready_videoToEx.save()

        #Create brand new copies of draft relationships
            for draft_videoToEx in draft_videoToExs:
                ready_videoToEx = VideoToExercise(video = ready_instance,
                                                    exercise = draft_videoToEx.exercise,
                                                    video_time = draft_videoToEx.video_time,
                                                    is_deleted = 0,
                                                    mode = 'ready',
                                                    image = draft_videoToEx)
                ready_videoToEx.save()
                draft_videoToEx.image = ready_videoToEx
                draft_videoToEx.save()

        else:
            draft_videoToExs = VideoToExercise.objects.getByVideo(self)
            for draft_videoToEx in draft_videoToExs:
                draft_videoToEx.image.video_time = draft_videoToEx.video_time
                draft_videoToEx.image.save()

    def revert(self, clone_fields = None):
        if self.mode != 'draft': return;

        ready_instance = self.image
        if not clone_fields or 'title' in clone_fields:
            self.title = ready_instance.title
        if not clone_fields or 'section' in clone_fields:
            self.section = ready_instance.section.image
        if not clone_fields or 'description' in clone_fields:
            self.description = ready_instance.description
        if not clone_fields or 'slug' in clone_fields:
            self.slug = ready_instance.slug
        if not clone_fields or 'file' in clone_fields:
            self.file = ready_instance.file
        if not clone_fields or 'url' in clone_fields:
            self.url = ready_instance.url
        if not clone_fields or 'live_datetime' in clone_fields:
            self.live_datetime = ready_instance.live_datetime

        self.save()

        if self.exercises_changed() == True:
            draft_videoToExs = VideoToExercise.objects.getByVideo(self)
            ready_videoToExs = VideoToExercise.objects.getByVideo(ready_instance)
            #Delete all previous relationships
            for draft_videoToEx in draft_videoToExs:
                draft_videoToEx.delete()
                draft_videoToEx.save()

        #Create brand new copies of draft relationships
            for ready_videoToEx in ready_videoToExs:
                draft_videoToEx = VideoToExercise(video = self,
                                                    exercise = ready_videoToEx.exercise,
                                                    video_time = ready_videoToEx.video_time,
                                                    is_deleted = 0,
                                                    mode = 'draft',
                                                    image = ready_videoToEx)
                draft_videoToEx.save()
                ready_videoToEx.image = draft_videoToEx
                ready_videoToEx.save()

        else:
            ready_videoToExs = VideoToExercise.objects.getByVideo(ready_instance)
            for ready_videoToEx in ready_videoToExs:
                ready_videoToEx.image.video_time = ready_videoToEx.video_time
                ready_videoToEx.image.save()

    def is_synced(self):
        prod_instance = self.image
        if self.exercises_changed() == True:
            return False
        if self.title != prod_instance.title:
            return False
        if self.section != prod_instance.section.image:
            return False
        if self.description != prod_instance.description:
            return False
        if self.slug != prod_instance.slug:
            return False
        if self.file != prod_instance.file:
            return False
        if self.url != prod_instance.url:
            return False
        if self.live_datetime != prod_instance.live_datetime:
            return False
        draft_videoToExs = VideoToExercise.objects.getByVideo(self)
        for draft_videoToEx in draft_videoToExs:
            if draft_videoToEx.video_time != draft_videoToEx.image.video_time:
                return False
        return True

    def dl_link(self):
        if not self.file.storage.exists(self.file.name):
            return ""
        return self.file.storage.url(self.file.name, response_headers={'response-content-disposition': 'attachment'})

    def ret_url(self):
        return "https://www.youtube.com/analytics#fi=v-" + self.url + ",r=retention"

    def runtime(self):
        if not self.duration:
            return "Runtime not yet available"
        m, s = divmod(self.duration, 60)
        h, m = divmod(m, 60)
        if h:
            return "%d:%02d:%02d" % (h, m, s)
        else:
            return "%d:%02d" % (m, s)

    def validate_unique(self, exclude=None):
        errors = {}

        try:
            super(Video, self).validate_unique(exclude=exclude)
        except ValidationError, e:
            errors.update(e.message_dict)

        # Special slug uniqueness validation for course
        slug_videos = Video.objects.filter(course=self.course,is_deleted=0,slug=self.slug)

        # Exclude the current object from the query if we are editing an
        # instance (as opposed to creating a new one)
        if not self._state.adding and self.pk is not None:
            slug_videos = slug_videos.exclude(pk=self.pk)

        if slug_videos.exists():
            errors.setdefault("slug", []).append("Video with this URL identifier already exists.")

        if errors:
            raise ValidationError(errors)
Ejemplo n.º 14
0
class Release(models.Model):
    """
    DCRM Base Model: Release
    This model manages releases (repository control info),
    and all package list builds will be assigned to one of
    these instances.
    """

    class Meta(object):
        verbose_name = _("Release")
        verbose_name_plural = _("Releases")

    # Base Property
    id = models.AutoField(primary_key=True, editable=False)
    created_at = models.DateTimeField(
        verbose_name=_("Created At"),
        auto_now_add=True
    )

    origin = models.CharField(
        verbose_name=_("Origin"),
        max_length=255,
        help_text=_("This is used by Cydia as the name of the repository as shown in the "
                    "source editor (and elsewhere). This should be a longer, but not insanely "
                    "long, description of the repository."),
        default=""
    )

    label = models.CharField(
        verbose_name=_("Label"),
        max_length=255,
        help_text=_("On the package list screens, Cydia shows what repository and section "
                    "packages came from. This location doesn't have much room, though, so "
                    "this field should contain a shorter/simpler version of the name of the "
                    "repository that can be used as a tag."),
        default=""
    )

    suite = models.CharField(
        verbose_name=_("Suite"),
        max_length=255,
        help_text=_("Just set this to \"stable\". This field might not be required, but who "
                    "really knows? I, for certain, do not."),
        default=_("stable"),
        blank=True,
        validators=[
            validate_slug
        ]
    )

    version = models.CharField(
        verbose_name=_("Version"),
        max_length=255,
        help_text=_("This is an arbitrary version number that nothing actually parses. "
                    "I am going to look into seeing how required it is."),
        default=_("0.0.1-1"),
    )

    codename = models.CharField(
        verbose_name=_("Codename"),
        max_length=255,
        blank=True,
        default="",
        help_text=_("In an \"automatic\" repository you might store multiple distributions "
                    "of software for different target systems. For example: apt.saurik.com's "
                    "main repository houses content both for desktop Debian Etch systems as "
                    "well as the iPhone. This codename then describes what distribution we "
                    "are currently looking for.")
    )

    architectures = models.CharField(
        verbose_name=_("Architectures"),
        max_length=255,
        help_text=_("To verify a repository is for the specific device you are working with "
                    "APT looks in the release file for this list. You must specify all of the "
                    "architectures that appear in your Packages file here. Again, we use "
                    "darwin-arm for 1.1.x and iphoneos-arm for 2.x."),
        default=_("iphoneos-arm"),
        blank=True
    )

    components = models.CharField(
        verbose_name=_("Components"),
        max_length=255,
        help_text=_("Just set this to \"main\". This field might not be required, but who "
                    "really knows? I, for certain, do not."),
        default=_("main"),
        blank=True,
        validators=[
            validate_slug
        ]
    )

    description = models.TextField(
        verbose_name=_("Description"),
        blank=True,
        help_text=_("On the package source screen a short description is listed of the repository. "
                    "This description may eventually work similarly to that of a package (with a "
                    "long/short variety and the aforementioned encoding), but for right now only "
                    "the shorter description is displayed directly on the list.")
    )

    keywords = models.CharField(
        verbose_name=_("Keywords"),
        max_length=255,
        help_text=_("Separated by commas."),
        default="",
        blank=True
    )

    # Warning: this field will store icon/file relative to MEDIA_URL,
    #          defined in settings.py.
    icon = models.FileField(
        verbose_name=_("Repository Icon"),
        max_length=255,
        upload_to="repository-icons",
        help_text=_("Choose an Icon (*.png) to upload"),
        blank=True,
        null=True,
        validators=[
            FileExtensionValidator(allowed_extensions=['png'])
        ]
    )

    support = models.URLField(
        verbose_name=_("Support"),
        max_length=255,
        help_text=_("Official site to provide support."),
        blank=True,
        null=True
    )

    email = models.EmailField(
        verbose_name=_("E-mail"),
        max_length=255,
        help_text=_("Maintainer's E-mail to provide support."),
        blank=True,
        null=True
    )

    def __str__(self):
        return self.label + " (" + self.origin + ")"

    @staticmethod
    def get_change_list_url():
        """
        :return: URL String
        :rtype: str
        """
        content_type = ContentType.objects.get_for_model(Release)
        return urlresolvers.reverse(
            "admin:%s_%s_changelist" % (content_type.app_label, content_type.model)
        )
    
    def get_admin_url(self):
        """
        :return: URL String
        :rtype: str
        """
        content_type = ContentType.objects.get_for_model(self.__class__)
        return urlresolvers.reverse(
            "admin:%s_%s_change" % (content_type.app_label, content_type.model),
            args=(self.id,)
        )
    
    def get_external_icon_link(self):
        """
        This getter method for icon_link property generates outer
        link for frontend icon display.

        :return: External Icon Link
         :rtype: str
        """
        if not self.icon:
            return None
        file_path = self.icon.name
        return str(preferences.Setting.resources_alias) + file_path
    
    icon_link = property(get_external_icon_link)
    
    def get_control_field(self):
        # original
        """
        Generate control dictionary from instance properties

        :rtype: dict
        :return: No return value
        """
        """
        Standard Keys
        """
        control_field = {
            "Origin": self.origin,
            "Label": self.label,
            "Suite": self.suite,
            "Version": self.version,
            "Codename": self.codename,
            "Architectures": self.architectures,
            "Components": self.components,
            "Description": self.description,
            "Support": self.support,
        }
        control = {}
        for (k, v) in control_field.items():
            if v is not None and len(str(v)) > 0:
                control[k] = str(v)
        return control
Ejemplo n.º 15
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('course', '0001_initial'),
        ('quiz', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Video',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=100)),
                ('description', models.TextField(blank=True)),
                ('video_file', models.FileField(upload_to=video.models.video_upload_path)),
                ('doc_file', models.FileField(blank=True, null=True, upload_to=video.models.video_doc_upload_path)),
                ('in_video_quiz_file', models.FileField(blank=True, null=True, upload_to=video.models.in_video_quiz_upload_path)),
                ('video_duration', models.DurationField()),
                ('uploaded_on', models.DateTimeField(auto_now_add=True)),
                ('modified_on', models.DateTimeField(auto_now=True)),
                ('chapter', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='course.chapter')),
                ('section', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='course.section')),
            ],
        ),
        migrations.CreateModel(
            name='VideoHistory',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('video_watched_duration', models.DurationField()),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
                ('video', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='video.video')),
            ],
        ),
        migrations.CreateModel(
            name='SectionMarker',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('time', models.DurationField()),
                ('title', models.CharField(max_length=100)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('modified_on', models.DateTimeField(auto_now=True)),
                ('video', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='video.video')),
            ],
        ),
        migrations.CreateModel(
            name='QuizMarker',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('time', models.DurationField()),
                ('title', models.CharField(max_length=100)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('modified_on', models.DateTimeField(auto_now=True)),
                ('quiz', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='quiz.quiz')),
                ('video', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='video.video')),
            ],
        ),
        migrations.AddConstraint(
            model_name='video',
            constraint=models.CheckConstraint(check=models.Q(('chapter__isnull', False), ('section__isnull', False), _connector='OR'), name='both_not_null_in_video'),
        ),
        migrations.AddConstraint(
            model_name='sectionmarker',
            constraint=models.UniqueConstraint(fields=('video', 'time'), name='unique_section_marker'),
        ),
        migrations.AddConstraint(
            model_name='quizmarker',
            constraint=models.UniqueConstraint(fields=('video', 'time'), name='unique_quiz_marker'),
        ),
    ]
Ejemplo n.º 16
0
class Song(models.Model):
    album = models.ForeignKey(MusicAlbum)
    name = models.CharField(max_length=255)
    file = models.FileField(upload_to='songs/')
Ejemplo n.º 17
0
class PageFile(TitleAbstractBase):
    """ File related to an page. """
    
    page = models.ForeignKey(Page)
    file = models.FileField(verbose_name=_('file'), upload_to='page_files')
Ejemplo n.º 18
0
class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='ActionHistoryEntry',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField()),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('invoker', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='action_history_entries', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Applicant',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('id_number', models.CharField(max_length=255)),
                ('username', models.CharField(max_length=255)),
                ('userid', models.CharField(max_length=255)),
                ('first_name', models.CharField(blank=True, max_length=255, null=True)),
                ('second_name', models.CharField(blank=True, max_length=255, null=True)),
                ('third_name', models.CharField(blank=True, max_length=255, null=True)),
                ('last_name', models.CharField(blank=True, max_length=255, null=True)),
                ('email', models.CharField(max_length=255)),
                ('mobile', models.CharField(blank=True, max_length=20, null=True)),
                ('countryid', models.CharField(max_length=50)),
                ('birthdate', models.DateField()),
                ('birthdatehijri', models.DateField()),
                ('legal_status', models.IntegerField(blank=True, null=True)),
                ('person_type', models.IntegerField(blank=True, null=True)),
                ('gender', models.CharField(max_length=10)),
                ('has_wasel_account', models.BooleanField(default=False)),
            ],
        ),
        migrations.CreateModel(
            name='ApplicantType',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('value', models.IntegerField(choices=[(1, 'Individual'), (2, 'Company')])),
            ],
        ),
        migrations.CreateModel(
            name='Application',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('serial', models.CharField(max_length=255)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('applicant', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='main.Applicant')),
            ],
        ),
        migrations.CreateModel(
            name='ApplicationComment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField()),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='main.Application')),
                ('poster', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='ApplicationDocument',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('file', models.FileField(upload_to=main.models.application_docs_upload_to)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='main.Application')),
            ],
        ),
        migrations.CreateModel(
            name='ApplicationStatus',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('value', models.IntegerField(choices=[(1, 'New'), (2, 'In revision'), (3, 'In manager'), (4, 'In president'), (5, 'On hold'), (6, 'Rejected'), (7, 'Finished')], unique=True)),
            ],
        ),
        migrations.AddField(
            model_name='application',
            name='status',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='main.ApplicationStatus'),
        ),
        migrations.AddField(
            model_name='applicant',
            name='usertype',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='main.ApplicantType'),
        ),
    ]
Ejemplo n.º 19
0
class File(models.Model):
    file = models.FileField(blank=False, null=False)

    def __str__(self):
        return self.file.name
Ejemplo n.º 20
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Char',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=1)),
            ],
            options={
                'ordering': ('name', ),
            },
        ),
        migrations.CreateModel(
            name='CharInSource',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('page', models.IntegerField()),
                ('char',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='chars.Char')),
            ],
        ),
        migrations.CreateModel(
            name='Source',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title', models.CharField(max_length=200)),
                ('author', models.CharField(max_length=200)),
                ('file', models.FileField(upload_to='uploads/')),
                ('offset', models.IntegerField(default=0)),
            ],
            options={
                'ordering': ('title', ),
            },
        ),
        migrations.AddField(
            model_name='charinsource',
            name='source',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='chars.Source'),
        ),
        migrations.AddField(
            model_name='char',
            name='location',
            field=models.ManyToManyField(through='chars.CharInSource',
                                         to='chars.Source'),
        ),
    ]
Ejemplo n.º 21
0
class Image(ItemBase):
    file = models.FileField(upload_to='images')
Ejemplo n.º 22
0
class File(models.Model):
    filename = models.FileField()
    note = models.TextField(blank=True, null=True)
    add_time = models.DateTimeField(auto_now_add=True)
    update_time = models.DateTimeField(auto_now=True)
Ejemplo n.º 23
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Book',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True)),
                ('description',
                 models.CharField(blank=True,
                                  help_text='请填写相关描述信息',
                                  max_length=200)),
                ('author', models.CharField(blank=True, max_length=50)),
                ('book_type',
                 models.CharField(choices=[[
                     'Hacker',
                     [('book_type1', 'Python'), ('book_type2', 'Linux'),
                      ('book_type3', '网络'), ('book_type4', '运维'),
                      ('book_type5', '数据库'), ('book_type6', '前端'),
                      ('book_type7', '测试')]
                 ], ('book_type7', '历史'), ('book_type8', '人物传记'),
                                           ('book_type9', '技能、训练'),
                                           ('book_type10', '思想哲学'),
                                           ('book_type11', 'IT行业'),
                                           ('book_type12', '小说'),
                                           ('book_type13', '其他')],
                                  max_length=20)),
                ('book_step',
                 models.CharField(choices=[('book_step1', '待下载'),
                                           ('book_step2', '已下载'),
                                           ('book_step3', '已审核'),
                                           ('book_step4', '阅读中'),
                                           ('book_step5', '已读完')],
                                  max_length=20)),
                ('book_file',
                 models.FileField(blank=True, upload_to='date_manage/book/')),
                ('creator', models.CharField(max_length=100)),
                ('create_date', models.DateField(auto_now_add=True,
                                                 null=True)),
                ('update_date', models.DateField(auto_now=True, null=True)),
            ],
            options={
                'verbose_name': '书籍管理',
                'verbose_name_plural': '书籍管理',
                'ordering': ('name', ),
            },
        ),
        migrations.CreateModel(
            name='Game',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True)),
                ('description',
                 models.TextField(blank=True, help_text='请填写相关描述信息和备注')),
                ('game_type',
                 models.CharField(blank=True,
                                  choices=[('game_type1', '射击'),
                                           ('game_type2', '第一人称射击'),
                                           ('game_type3', '第三人称射击'),
                                           ('game_type4', '动作'),
                                           ('game_type5', '角色扮演'),
                                           ('game_type6', '动作角色扮演'),
                                           ('game_type7', '策略'),
                                           ('game_type8', '竞速'),
                                           ('game_type9', '模拟器'),
                                           ('game_type10', '休闲')],
                                  max_length=20)),
                ('game_step',
                 models.CharField(blank=True,
                                  choices=[('movie_step1', '待下载'),
                                           ('movie_step2', '已下载'),
                                           ('movie_step3', '已审核')],
                                  max_length=20)),
                ('seed_address', models.CharField(blank=True, max_length=200)),
                ('seed_type',
                 models.CharField(blank=True,
                                  choices=[('seed_address1', '百度云'),
                                           ('seed_address2', '迅雷')],
                                  max_length=50)),
                ('creator', models.CharField(max_length=100)),
                ('create_date', models.DateField(auto_now_add=True,
                                                 null=True)),
                ('update_date', models.DateField(auto_now=True, null=True)),
            ],
            options={
                'verbose_name': '游戏管理',
                'verbose_name_plural': '游戏管理',
                'ordering': ('name', ),
            },
        ),
        migrations.CreateModel(
            name='Movie',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True)),
                ('description',
                 models.CharField(blank=True,
                                  help_text='请填写相关描述信息',
                                  max_length=200)),
                ('movie_type',
                 models.CharField(blank=True,
                                  choices=[[
                                      '电影',
                                      [('movie_type1', '大陆'),
                                       ('movie_type2', '香港'),
                                       ('movie_type3', '美国'),
                                       ('movie_type4', '欧洲'),
                                       ('movie_type5', '日韩'),
                                       ('movie_type6', '东南亚'),
                                       ('movie_type7', '其他')]
                                  ],
                                           [
                                               '电视剧',
                                               [('movie_type8', '大陆'),
                                                ('movie_type9', '香港'),
                                                ('movie_type10', '美国'),
                                                ('movie_type11', '欧洲'),
                                                ('movie_type12', '日韩'),
                                                ('movie_type13', '其他')]
                                           ]],
                                  max_length=20)),
                ('movie_step',
                 models.CharField(blank=True,
                                  choices=[('movie_step1', '待下载'),
                                           ('movie_step2', '已下载'),
                                           ('movie_step3', '已审核')],
                                  max_length=20)),
                ('seed_address', models.CharField(blank=True, max_length=200)),
                ('seed_type',
                 models.CharField(blank=True,
                                  choices=[('seed_address1', '百度云'),
                                           ('seed_address2', '迅雷')],
                                  max_length=50)),
                ('creator', models.CharField(max_length=100)),
                ('create_date', models.DateField(auto_now_add=True,
                                                 null=True)),
                ('update_date', models.DateField(auto_now=True, null=True)),
            ],
            options={
                'verbose_name': '电影管理',
                'verbose_name_plural': '电影管理',
                'ordering': ('name', ),
            },
        ),
        migrations.CreateModel(
            name='Music',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True)),
                ('description',
                 models.CharField(blank=True,
                                  help_text='请填写相关描述信息',
                                  max_length=200)),
                ('singer', models.CharField(blank=True, max_length=50)),
                ('album', models.CharField(blank=True, max_length=100)),
                ('music_format',
                 models.CharField(blank=True,
                                  choices=[('music_format1', 'FLAC'),
                                           ('music_format2', 'APE'),
                                           ('music_format3', 'mp3'),
                                           ('music_format4', 'WAV'),
                                           ('music_format5', '其他')],
                                  max_length=20)),
                ('music_type',
                 models.CharField(blank=True,
                                  choices=[('music_type1', '轻音乐'),
                                           ('music_type2', '流行歌曲'),
                                           ('music_type3', '其他')],
                                  max_length=20)),
                ('music_step',
                 models.CharField(blank=True,
                                  choices=[('book_step1', '待下载'),
                                           ('book_step2', '已下载'),
                                           ('book_step3', '已审核')],
                                  max_length=20)),
                ('music_file',
                 models.FileField(blank=True, upload_to='date_manage/music/')),
                ('creator', models.CharField(max_length=100)),
                ('create_date', models.DateField(auto_now_add=True,
                                                 null=True)),
                ('update_date', models.DateField(auto_now=True, null=True)),
            ],
            options={
                'verbose_name': '音乐管理',
                'verbose_name_plural': '音乐管理',
                'ordering': ('name', ),
            },
        ),
        migrations.CreateModel(
            name='Video',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True)),
                ('description',
                 models.CharField(blank=True,
                                  help_text='请填写相关描述信息',
                                  max_length=200)),
                ('video_type',
                 models.CharField(blank=True,
                                  choices=[('video_type1', 'IT'),
                                           ('video_type2', '社会'),
                                           ('video_type3', '演讲'),
                                           ('video_type4', '科教'),
                                           ('video_type5', '纪录片'),
                                           ('video_type6', '其他')],
                                  max_length=20)),
                ('video_step',
                 models.CharField(blank=True,
                                  choices=[('video_step1', '待下载'),
                                           ('video_step2', '已下载'),
                                           ('video_step3', '已审核')],
                                  max_length=20)),
                ('seed_address', models.CharField(blank=True, max_length=200)),
                ('seed_type',
                 models.CharField(blank=True,
                                  choices=[('seed_address1', '百度云'),
                                           ('seed_address2', '迅雷')],
                                  max_length=50)),
                ('creator', models.CharField(max_length=100)),
                ('create_date', models.DateField(auto_now_add=True,
                                                 null=True)),
                ('update_date', models.DateField(auto_now=True, null=True)),
            ],
            options={
                'verbose_name': '视频管理',
                'verbose_name_plural': '视频管理',
                'ordering': ('name', ),
            },
        ),
    ]
Ejemplo n.º 24
0
class Document(models.Model):
    title  = models.CharField(max_length=120)
    docfile = models.FileField(upload_to='documents/%Y/%m/%d')
Ejemplo n.º 25
0
class ArquivosResposta(models.Model):
    resposta = models.ForeignKey(Resposta)
    arquivo = models.FileField(upload_to="arquivosR/")
Ejemplo n.º 26
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('auth', '0011_update_proxy_permissions'),
    ]

    operations = [
        migrations.CreateModel(
            name='Fase',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nombre', models.CharField(max_length=40)),
            ],
            options={
                'permissions': (('create_item', 'Can create item'), ('aprove_item', 'Can aprove item'), ('unable_item', 'Can unable item'), ('reversionar_item', 'Reversionar item'), ('relacionar_item', 'Relacionar item'), ('change_item', 'Can change item'), ('establecer_itemPendienteAprob', 'Establecer ítem como pendiente de aprobación.'), ('establecer_itemDesarrollo', 'Establecer ítem como en desarrollo.'), ('obtener_trazabilidadItem', 'Obtener trazabilidad de ítem.'), ('view_item', 'Visualizar ítem.'), ('deshabilitar_item', 'Deshabilitar Item'), ('obtener_calculoImpacto', 'Obtener cálculo de impacto de ítem.'), ('create_lineaBase', 'Crear Línea Base.'), ('solicitar_roturaLineaBase', 'Solicitar rotura de línea base.')),
            },
        ),
        migrations.CreateModel(
            name='FaseUser',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('fase', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='proyecto.Fase')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Proyecto',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nombre', models.CharField(max_length=200)),
                ('descripcion', models.CharField(blank=True, max_length=400)),
                ('fecha_inicio', models.CharField(max_length=200)),
                ('fecha_fin', models.CharField(max_length=200)),
                ('estado', models.CharField(default=None, max_length=100, null=True)),
                ('comite', models.ManyToManyField(default=None, related_name='comite', to=settings.AUTH_USER_MODEL)),
                ('creador', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='creador', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Proyecto',
                'verbose_name_plural': 'Proyectos',
                'ordering': ['nombre'],
                'permissions': (('is_gerente', 'Can do anything in project'), ('create_tipoItem', 'Crear tipo de item'), ('import_tipoItem', 'Importar tipo de item'), ('view_tipoItem', 'Visualizar tipo de ítem.'), ('change_tipoItem', 'Modificar tipo de item'), ('delete_tipoItem', 'Eliminar tipo de item'), ('add_miembros', 'Can add miembros'), ('delete_miembros', 'Can delete miembros'), ('view_miembros', 'Can view miembros'), ('create_rol', 'Can create rol'), ('change_rol', 'Can change rol'), ('delete_rol', 'Can delete rol'), ('view_rol', 'Can view rol'), ('assign_rol', 'Can assign rol'), ('remove_rol', 'Can remove rol'), ('create_comite', 'Can create comite'), ('change_comite', 'Can change comite'), ('view_comite', 'Can view_comite comite'), ('aprobar_rotura_lineaBase', 'Romper Línea Base.')),
            },
        ),
        migrations.CreateModel(
            name='TipodeItem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nombre', models.CharField(max_length=40)),
                ('descripcion', models.CharField(max_length=40)),
                ('campo_extra', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=40), blank=True, default=list, size=None)),
                ('campo_extra_valores', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=40), blank=True, default=list, size=None)),
                ('file', models.FileField(blank=True, upload_to='media')),
            ],
        ),
        migrations.CreateModel(
            name='Rol',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nombre', models.CharField(max_length=40, unique=True)),
                ('faseUser', models.ManyToManyField(default=None, to='proyecto.FaseUser')),
                ('perms', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='auth.Group')),
            ],
        ),
        migrations.CreateModel(
            name='ProyectoFase',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('fase', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='proyecto.Fase')),
                ('proyecto', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='proyecto.Proyecto')),
            ],
        ),
        migrations.AddField(
            model_name='proyecto',
            name='fases',
            field=models.ManyToManyField(default=None, through='proyecto.ProyectoFase', to='proyecto.Fase'),
        ),
        migrations.AddField(
            model_name='proyecto',
            name='gerente',
            field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, related_name='gerente', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='proyecto',
            name='roles',
            field=models.ManyToManyField(default=None, to='proyecto.Rol'),
        ),
        migrations.AddField(
            model_name='proyecto',
            name='usuarios',
            field=models.ManyToManyField(default=None, to=settings.AUTH_USER_MODEL),
        ),
    ]
class Migration(migrations.Migration):

    dependencies = [
        ('proceso', '0006_tarea_orden'),
    ]

    operations = [
        migrations.CreateModel(
            name='Campo',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('fecha_creacion', models.DateTimeField(auto_now_add=True, verbose_name='Fecha de creación')),
                ('fecha_actualizacion', models.DateTimeField(auto_now=True, null=True, verbose_name='Fecha de actualización')),
                ('label', models.CharField(max_length=100, verbose_name='Label')),
                ('name', models.CharField(max_length=100, verbose_name='Name')),
                ('tipo', models.CharField(choices=[('INPUT', 'Input'), ('TEXTAREA', 'Textarea'), ('PASSWORD', 'Password'), ('NUMBER', 'Number'), ('EMAIL', 'Email'), ('CHECKBOX', 'Checkbox'), ('RADIOBUTTON', 'Radio-button'), ('SELECT', 'Select'), ('BUTTON', 'Button'), ('SLIDER', 'Slider'), ('FILEINPUT', 'File-input'), ('SLIDETOGGLE', 'Slide-toggle'), ('DATE', 'Date'), ('DATETIMELOCAL', 'Date-time-local'), ('MONTH', 'Month'), ('TIME', 'Time'), ('URL', 'Url')], default='INPUT', max_length=15, verbose_name='Tipo')),
                ('requerido', models.BooleanField(default=False, verbose_name='Requerido')),
                ('flex', models.IntegerField(blank=True, default=100, null=True, verbose_name='Flex')),
                ('minimo', models.IntegerField(blank=True, null=True, verbose_name='Minimo')),
                ('maximo', models.IntegerField(blank=True, null=True, verbose_name='Maximo')),
                ('backgroud', models.CharField(blank=True, max_length=300, null=True, verbose_name='Backgroud')),
                ('modelo', models.CharField(blank=True, max_length=200, null=True, verbose_name='Modelo')),
                ('json', models.TextField(blank=True, null=True, verbose_name='Json')),
                ('icon', models.CharField(blank=True, max_length=50, null=True, verbose_name='Icon')),
                ('prefix', models.CharField(blank=True, max_length=50, null=True, verbose_name='Prefix')),
                ('hint_start', models.CharField(blank=True, max_length=200, null=True, verbose_name='Hint_start')),
                ('hint_end_count_text', models.BooleanField(default=False, verbose_name='Hint_end_count_text')),
                ('disabled', models.BooleanField(default=False, verbose_name='Disabled')),
                ('multiselect', models.NullBooleanField(default=False, verbose_name='Multiselect')),
            ],
            options={
                'verbose_name': 'campo',
                'verbose_name_plural': 'campo',
            },
        ),
        migrations.CreateModel(
            name='CampoValor',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('fecha_creacion', models.DateTimeField(auto_now_add=True, verbose_name='Fecha de creación')),
                ('fecha_actualizacion', models.DateTimeField(auto_now=True, null=True, verbose_name='Fecha de actualización')),
                ('valorFileInput', models.FileField(blank=True, null=True, upload_to='proceso/valor-file-inputs/', verbose_name='ValorFileInput')),
                ('campo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='campovalor', to='proceso.Campo', verbose_name='Campo')),
            ],
            options={
                'verbose_name': 'campoValor',
                'verbose_name_plural': 'campoValors',
            },
        ),
        migrations.CreateModel(
            name='Formulario',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('fecha_creacion', models.DateTimeField(auto_now_add=True, verbose_name='Fecha de creación')),
                ('fecha_actualizacion', models.DateTimeField(auto_now=True, null=True, verbose_name='Fecha de actualización')),
                ('nombre', models.CharField(max_length=300, verbose_name='Nombre')),
                ('alias', models.CharField(blank=True, max_length=100, null=True, verbose_name='Alias')),
                ('descripcion', models.TextField(blank=True, null=True, verbose_name='Descripción')),
                ('tarea', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='formulario', to='proceso.Tarea', verbose_name='Tarea')),
            ],
            options={
                'verbose_name': 'formulario',
                'verbose_name_plural': 'formularios',
            },
        ),
        migrations.AddField(
            model_name='campo',
            name='formulario',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='campo', to='proceso.Formulario', verbose_name='Formulario'),
        ),
    ]
class Migration(migrations.Migration):

    dependencies = [
        ('website', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Booklet',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title', models.CharField(max_length=200)),
                ('slug', models.SlugField(default=None, null=True)),
                ('owner',
                 models.CharField(blank=True, default='ناشناس',
                                  max_length=200)),
                ('number_of_views',
                 models.IntegerField(
                     default=0,
                     help_text=
                     'لطفا مقدار را عوض نکنید ( به جز در مواقع نیاز شدید و باگ)',
                     verbose_name='تعداد بازدید')),
                ('booklet_content',
                 models.FileField(upload_to='website/booklet_content')),
                ('booklet_image',
                 models.ImageField(upload_to='website/booklet_images')),
            ],
        ),
        migrations.CreateModel(
            name='BookletField',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('subject', models.CharField(max_length=120, null=True)),
                ('slug', models.SlugField(help_text='Lower case', null=True)),
            ],
        ),
        migrations.CreateModel(
            name='BookletTopic',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('subject',
                 models.CharField(help_text='Booklet topic',
                                  max_length=120,
                                  verbose_name='عنوان')),
                ('slug', models.SlugField(help_text='Lower case', null=True)),
                ('field',
                 models.ForeignKey(null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   related_name='topics',
                                   to='website.BookletField')),
            ],
        ),
        migrations.CreateModel(
            name='UserUploadedBooklet',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title', models.CharField(max_length=120,
                                           verbose_name='عنوان')),
                ('field', models.CharField(max_length=120,
                                           verbose_name='رشته')),
                ('topic', models.CharField(max_length=120,
                                           verbose_name='درس')),
                ('writer',
                 models.CharField(max_length=120, verbose_name='نویسنده')),
                ('booklet_file',
                 models.FileField(blank=True,
                                  null=True,
                                  upload_to='website/tmp_booklet_content')),
                ('status',
                 models.CharField(blank=True,
                                  choices=[('seen', 'مشاهده شد'),
                                           ('pending', 'در حال انجام'),
                                           ('finished', 'انجام شد'),
                                           ('canceled', 'لغو شد')],
                                  default='seen',
                                  help_text='وضعیت دانلود و آپلود جزوه اصلی',
                                  max_length=20)),
            ],
        ),
        migrations.RemoveField(
            model_name='post',
            name='created_date',
        ),
        migrations.RemoveField(
            model_name='post',
            name='published_date',
        ),
        migrations.AddField(
            model_name='post',
            name='post_image',
            field=models.ImageField(blank=True,
                                    upload_to='website/post_images'),
        ),
        migrations.AddField(
            model_name='post',
            name='slug',
            field=models.SlugField(default=uuid.uuid1),
        ),
        migrations.AddField(
            model_name='topic',
            name='hello',
            field=models.CharField(default='dd', max_length=120),
        ),
        migrations.AddField(
            model_name='topic',
            name='parent',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='children',
                to='website.Topic'),
        ),
        migrations.AddField(
            model_name='topic',
            name='slug',
            field=models.SlugField(default=models.CharField(max_length=120),
                                   unique=True),
        ),
        migrations.AddField(
            model_name='booklet',
            name='topic',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='booklets',
                to='website.BookletTopic'),
        ),
    ]
class Customer(models.Model):
    name = models.CharField(max_length=100)
    # file will be uploaded to MEDIA_ROOT/uploads
    upload = models.FileField(upload_to='uploads/')
Ejemplo n.º 30
0
class Talk(models.Model):
    # id = models.AutoField(primary_key=True)
    content = models.TextField(blank=True, null=True)
    image = models.FileField(upload_to="images/", blank=True, null=True)