<commit_before># -*- coding: utf-8 -*-

from django.db import models
from django.contrib.auth.models import User
import datetime

class CustomUser(models.Model):
    user = models.OneToOneField(User, primary_key=True)
    image = models.ImageField(upload_to='avatars', null=True, blank=True)

    def __unicode__(self):
        return self.user.username

class Recipe(models.Model):
    title = models.CharField(max_length=200, blank=False)
    text = models.TextField(blank=False)
    image = models.ImageField(upload_to='photos', null=True, blank=False)
    date = models.DateTimeField(auto_now_add=True, editable=False)
    likes = models.IntegerField(default=0, editable=False)
    user = models.ForeignKey(CustomUser, related_name='recipes')

    class Meta:
        ordering = ['likes', 'date']

    def __unicode__(self):
        return self.title

    def like_recipe(recipe, user):
        try:
            UserRecipe.objects.get(user=user, recipe=recipe)
        except:
            # like još ne postoji
            ur = UserRecipe(user=user, recipe=recipe)
            ur.save()

class Discount(models.Model):
    text = models.TextField(blank=False, max_length=200)
    date = models.DateTimeField(auto_now_add=True, editable=False)
    user = models.ForeignKey(CustomUser, related_name='discounts')

    class Meta:
        ordering = ['date']

    def __unicode__(self):
        return self.title

class Category(models.Model):
    name = models.CharField(max_length=200, unique=True, blank=False)

    class Meta:
        ordering = ['name']

    def __unicode__(self):
        return self.name

class Tag(models.Model):
    name = models.CharField(max_length=200, unique=True, blank=False)
<commit_msg>ispravak<commit_after># -*- coding: utf-8 -*-

from django.db import models
from django.contrib.auth.models import User
import datetime

class CustomUser(models.Model):
    user = models.OneToOneField(User, primary_key=True)
    image = models.ImageField(upload_to='avatars', null=True, blank=True)

    def __unicode__(self):
        return self.user.username

class Recipe(models.Model):
    title = models.CharField(max_length=200, blank=False)
    text = models.TextField(blank=False)
    image = models.ImageField(upload_to='photos', null=True, blank=True)
    date = models.DateTimeField(auto_now_add=True, editable=False)
    likes = models.IntegerField(default=0, editable=False)
    user = models.ForeignKey(CustomUser, related_name='recipes')

    class Meta:
        ordering = ['likes', 'date']

    def __unicode__(self):
        return self.title

    def like_recipe(recipe, user):
        try:
            UserRecipe.objects.get(user=user, recipe=recipe)
        except:
            # like još ne postoji
            ur = UserRecipe(user=user, recipe=recipe)
            ur.save()

class Discount(models.Model):
    text = models.TextField(blank=False, max_length=200)
    date = models.DateTimeField(auto_now_add=True, editable=False)
    user = models.ForeignKey(CustomUser, related_name='discounts')

    class Meta:
        ordering = ['date']

    def __unicode__(self):
        return self.text

class Category(models.Model):
    name = models.CharField(max_length=200, unique=True, blank=False)

    class Meta:
        ordering = ['name']

    def __unicode__(self):
        return self.name

class Tag(models.Model):
    name = models.CharField(max_length=200, unique=True, blank=False)

{'fraction_non_alphanumeric': 0.11600116584086272, 'fraction_numerical': 0.00816088603905567, 'mean_word_length': 3.4862745098039216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3893818', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1044, 'n_words': 218}