Пример #1
0
class Profile(models.Model):
    user = models.OneToOneField(User,
                                on_delete=models.CASCADE,
                                null=True,
                                blank=True)
    profile_photo = models.ImageField(default='default.png',
                                      upload_to='profiles/')
    bio = HTMLField(max_length=500, default='Tell Me Something')
    website = URLOrRelativeURLField()
    phone_number = models.CharField(max_length=10, default=12345678)
    # projects = models.ForeignKey(Projects,on_delete=models.CASCADE,null=True)

    @receiver(post_save, sender=User)
    def create_profile(sender, instance, created, **kwargs):
        if created:
            Profile.objects.create(user=instance)

    @receiver(post_save, sender=User)
    def save_profile(sender, instance, **kwargs):
        instance.profile.save()

    @classmethod
    def get_by_id(cls, id):
        profile = Profile.objects.get(user=id)
        return profile

    @classmethod
    def filter_by_id(cls, id):
        profile = Profile.objects.filter(user=id).first()
        return profile

    def __str__(self):
        return self.bio
Пример #2
0
class Projects(models.Model):
    profile = models.ForeignKey(User, null=True, on_delete=models.CASCADE)
    title = models.CharField(max_length=20, blank=True)
    design = models.IntegerField(default=0)
    usability = models.IntegerField(default=0)
    content = models.IntegerField(default=0)
    image_landing = models.ImageField(upload_to='landing/')
    description = HTMLField(max_length=200, blank=True)
    link = URLOrRelativeURLField(max_length=200)
    pub_date = models.DateTimeField(auto_now_add=True)

    @classmethod
    def search_by_projects(cls, search_term):
        projects = cls.objects.filter(title__icontains=search_term)
        print(projects)
        return projects

    @classmethod
    def get_profile_projects(cls, profile):
        projects = Projects.objects.filter(profile__pk=profile)
        print(projects)
        return projects

    def __str__(self):
        return self.title
Пример #3
0
class Project(models.Model):
    title = models.CharField(max_length=50)
    category = models.ForeignKey(Category,
                                 on_delete=models.PROTECT,
                                 related_name='projects')
    languages = models.ManyToManyField(Language,
                                       related_name='projects',
                                       blank=True)
    frameworks = models.ManyToManyField(Framework,
                                        related_name='projects',
                                        blank=True)
    tools = models.ManyToManyField(Tool, related_name='projects', blank=True)
    concepts = models.ManyToManyField(Concept,
                                      related_name='projects',
                                      blank=True)
    desc_short = models.CharField(max_length=200)
    desc_long = models.TextField()
    proj_url = URLOrRelativeURLField()
    code_url = models.URLField(max_length=300, blank=True)
    publish = models.BooleanField(default=True)

    class Meta:
        ordering = ('title', 'category')

    def __str__(self):
        return self.title
Пример #4
0
class Project(models.Model):
    project_title = models.CharField(max_length=40)
    project_description = HTMLField()
    landing_page = CloudinaryField('image')
    live_site = URLOrRelativeURLField()
    user = models.ForeignKey(User,
                             null=True,
                             blank=True,
                             on_delete=models.CASCADE)
    design = models.IntegerField(choices=list(zip(range(0, 11), range(0, 11))),
                                 default=0)
    usability = models.IntegerField(choices=list(
        zip(range(0, 11), range(0, 11))),
                                    default=0)
    content = models.IntegerField(choices=list(zip(range(0, 11), range(0,
                                                                       11))),
                                  default=0)
    vote_submissions = models.IntegerField(default=0)

    def save_project(self):
        self.save()

    def delete_project(self):
        self.delete()

    def __str__(self):
        return self.project_title
Пример #5
0
class MenuItem(models.Model):

    label = models.CharField(
        max_length=25,
        help_text="This is the text that will appear for the menu item.")
    fa_icon = models.CharField(
        max_length=50,
        default="link",
        help_text=mark_safe(
            "The Font Awesome icon to display beside the text. E.g. 'star-o'. "
            "Options from <a target='_blank'"
            "href='http://fontawesome.com/v4.7.0/icons/'>Font Awesome</a>."))
    url = URLOrRelativeURLField(
        help_text="Relative URLs will work too.  E.g. '/courses/ranks/'")
    open_link_in_new_tab = models.BooleanField()
    sort_order = models.IntegerField(default=0,
                                     help_text="Lowest will be at the top.")
    visible = models.BooleanField(default=True)

    class Meta:
        ordering = ["sort_order"]

    def __str__(self):
        target = 'target="_blank"' if self.open_link_in_new_tab else ''
        return '<a href="{0}" {1}>' \
               '<i class="fa fa-fw fa-{2}"></i>&nbsp;&nbsp;{3}' \
               '</a>'.format(self.url, target, self.fa_icon, self.label)
Пример #6
0
class Profile(models.Model):
    user = models.OneToOneField(User,
                                on_delete=models.CASCADE,
                                null=True,
                                blank=True)
    profile_pic = models.ImageField(default='image.png', upload_to='profiles/')
    bio = HTMLField(max_length=500, default='About me')
    phone_number = models.CharField(max_length=10, default=000000)
    website = URLOrRelativeURLField()

    def save_profile(self):
        self.save()

    def delete_profile(self):
        self.delete()

    def update_profile(self):
        self.update()

    @classmethod
    def search_profile(cls, username):
        profile = Profile.objects.filter(user_id=username)

        return profile

    def __str__(self):
        return self.bio
Пример #7
0
class Project(models.Model):
    profile = models.ForeignKey(User, null=True, on_delete=models.CASCADE)
    title = models.CharField(max_length=100)
    description = models.TextField()
    #technology = models.CharField(max_length=20)
    image = models.ImageField(upload_to="projects/")
    # usability=models.IntegerField(default=0)
    # design=models.IntegerField(default=0)

    # content=models.IntegerField(default=0)
    link = URLOrRelativeURLField(max_length=200)
    pub_date = models.DateTimeField(auto_now_add=True)

    @classmethod
    def search_by_projects(cls, search_term):
        projects = cls.objects.filter(title__icontains=search_term)
        print(projects)
        return projects

    @classmethod
    def get_profile_projects(cls, profile):
        projects = Project.objects.filter(profile__pk=profile)
        print(projects)
        return projects

    @classmethod
    def search_project(cls, search_term):

        searched_item = Project.objects.filter(title__icontains=search_term)
        return searched_item

    def __str__(self):
        return self.title
Пример #8
0
class ConreqConfig(SingletonModel):
    # Basic settings
    conreq_api_key = models.CharField(max_length=255, default="", blank=True)
    conreq_app_name = models.CharField(max_length=100, default="Conreq")
    conreq_language = models.CharField(max_length=100, default="en")
    conreq_app_logo = models.ImageField(blank=True)
    conreq_app_url = models.URLField(default="", blank=True)
    conreq_custom_css = URLOrRelativeURLField(default="", blank=True)
    conreq_custom_js = URLOrRelativeURLField(default="", blank=True)
    conreq_simple_posters = models.BooleanField(default=True)
    conreq_auto_resolve_issues = models.BooleanField(default=True)
    conreq_guest_login = models.BooleanField(default=False)
    conreq_dark_theme = models.BooleanField(default=True)
    conreq_http_header_auth = models.BooleanField(default=False)
    conreq_initialized = models.BooleanField(default=False)

    # Sonarr settings
    sonarr_url = ExtendedURLField(default="", blank=True)
    sonarr_api_key = models.CharField(max_length=255, default="", blank=True)
    sonarr_anime_quality_profile = models.PositiveIntegerField(default=1)
    sonarr_anime_folder = models.PositiveIntegerField(default=1)
    sonarr_tv_quality_profile = models.PositiveIntegerField(default=1)
    sonarr_tv_folder = models.PositiveIntegerField(default=1)
    sonarr_enabled = models.BooleanField(default=False)
    sonarr_season_folders = models.BooleanField(default=True)

    # Radarr Settings
    radarr_url = ExtendedURLField(default="", blank=True)
    radarr_api_key = models.CharField(max_length=255, default="", blank=True)
    radarr_anime_quality_profile = models.PositiveIntegerField(default=1)
    radarr_anime_folder = models.PositiveIntegerField(default=1)
    radarr_movies_quality_profile = models.PositiveIntegerField(default=1)
    radarr_movies_folder = models.PositiveIntegerField(default=1)
    radarr_enabled = models.BooleanField(default=False)

    # Email settings
    email_smtp_server = models.CharField(max_length=255,
                                         default="",
                                         blank=True)
    email_smtp_port = models.PositiveIntegerField(default=587)
    email_username = EncryptedCharField(max_length=255, default="", blank=True)
    email_password = EncryptedCharField(max_length=255, default="", blank=True)
    email_sender_name = models.CharField(max_length=50, default="", blank=True)
    email_enable_tls = models.BooleanField(default=True)
Пример #9
0
class Profile(models.Model):
    '''
    The model class for user profiles
    '''
    user = models.OneToOneField(User,
                                on_delete=models.CASCADE,
                                null=True,
                                blank=True,
                                related_name='profile')
    profile_photo = models.ImageField(default='default.png',
                                      upload_to='profiles/')
    bio = HTMLField(max_length=500, default='Tell me about you')
    website = URLOrRelativeURLField()
    phone_number = models.CharField(max_length=10, default=12345678)
    '''
    Creating user profile and saving
    '''
    @receiver(post_save, sender=User)
    def create_profile(sender, instance, created, **kwargs):
        if created:
            Profile.objects.create(user=instance)

    @receiver(post_save, sender=User)
    def save_profile(sender, instance, **kwargs):
        instance.profile.save()

    def save_profile(self):
        self.user

    def update_profile_bio(self, new_bio):
        self.profile_bio = new_bio
        self.save()

    def update_profile_photo(self, new_photo):
        self.profile_photo = new_photo
        self.save()

    def delete_profile(self):
        self.delete()

    '''
    Query for user profiles [Parameter = ID]
    '''

    @classmethod
    def get_by_id(cls, id):
        profile = Profile.objects.get(user=id)
        return profile

    @classmethod
    def filter_by_id(cls, id):
        profile = Profile.objects.filter(user=id).first()
        return profile

    def __str__(self):
        return self.bio
Пример #10
0
class Project(models.Model):
    """
    class Project to create instances of projects uploaded to the site
    """

    project_title = models.CharField(max_length=200)
    project_image = models.ImageField(upload_to='projects/')
    project_description = HTMLField()
    live_link = URLOrRelativeURLField()
    upload_date = models.DateTimeField(auto_now_add=True)
    # posted_by=models.ForeignKey(User,default=1, on_delete=models.CASCADE)
    posted_by = models.ForeignKey(User, default=1, on_delete=models.CASCADE)

    # overall_rating=models.IntegerField(default=0)

    def save_project(self):
        """
        save project method to save project details provided 
        by the user to the database
        """
        self.save()

    def delete_project(self):
        """
        delete_project method to remove a project from the database
        """
        self.delete()

    def update_project(self):
        """
        update_project method to replace details of a given
        project in the database with new ones
        """
        self.update()

    @classmethod
    def search_project(cls, search_term):
        """
        searched_project method that finds the searched project
        in the database
        """
        searched_project = Project.objects.filter(
            project_title__icontains=search_term)
        return searched_project

    def __str__(self):
        return self.project_title
Пример #11
0
class UserProfile(models.Model):
    user = models.OneToOneField(User,on_delete=models.CASCADE)
    profile_pic = models.ImageField(upload_to='profile_photos',null=True,blank=True)
    bio = HTMLField()
    contact=models.CharField(max_length=12)
    linkedIn =  URLOrRelativeURLField()
    projects = models.ForeignKey('Project',on_delete=models.CASCADE,null=True)

    def save_profile(self):
        self.save()

    def delete_profile(self):
        self.delete()

    def update_bio(self,bio):
        self.bio = bio
        self.save()

    def __str__(self):
        return self.user.username
Пример #12
0
class Profile(models.Model):
    user = models.OneToOneField(User,
                                on_delete=models.CASCADE,
                                null=True,
                                blank=True)
    bio = HTMLField(max_length=300, default="No bio")
    profile_photo = models.ImageField(default='default.jpg',
                                      upload_to='profile_pics')
    website = URLOrRelativeURLField(default='')
    contact = models.CharField(max_length=50, default='*****@*****.**')

    def __str__(self):
        return f'{self.user.username} Profile'

    def save_profile(self):
        '''
        Saves profile instance to db
        '''
        self.save()

    @classmethod
    def get_by_id(cls, id):
        profile = Profile.objects.get(user=id)
        return profile

    @classmethod
    def filter_by_id(cls, id):
        profile = Profile.objects.filter(user=id).first()
        return profile

    @receiver(post_save, sender=User)
    def create_profile(sender, instance, created, **kwargs):
        if created:
            Profile.objects.create(user=instance)

    @receiver(post_save, sender=User)
    def save_profile(sender, instance, **kwargs):
        instance.profile.save()