<commit_before>from django.db import models
from django.core.exceptions import ValidationError
from kinetic_widget.forms import KineticFormField
# from kinetic_widget.forms import KineticWidget


class KineticField(models.TextField):
    description = "Kinetic field for graphic widget"

    def __init__(self, *args, **kwargs):
        defaults = {
            'help_text': 'Graphic widget',
            'default': '',
            # 'max_length': 1000,
        }
        defaults.update(kwargs)
        return super(KineticField, self).__init__(*args, **defaults)

    def formfield(self, **kwargs):
        defaults = {'form_class': KineticFormField}
        # defaults = {'widget': KineticWidget}
        defaults.update(kwargs)
        return super(KineticField, self).formfield(**defaults)



# TODO: delete these models (below). They are just for testing purposes.

def get_default_JSON():
	""" iba pre testovacie ucely """
	import urllib2
	response = urllib2.urlopen('http://team28-12.ucebne.fiit.stuba.sk/~kachman/value.json')
	json_data = response.read()
	# json_data = "<Test JSON>"
	# print(json_data)
	return str(json_data)

class TestWidgetSimple(models.Model):
	jeden = KineticField(default=get_default_JSON())  # TODO: bug v Djangu? (ked dam callable, tak to da ten input element dva krat za sebou!!!)

	class Meta:
	    verbose_name = 'Single Widget test'
	    verbose_name_plural = 'Single Widget tests'

<commit_msg>Fixed loading of default JSON from file<commit_after>from django.db import models
from django.core.exceptions import ValidationError
from kinetic_widget.forms import KineticFormField
# from kinetic_widget.forms import KineticWidget


class KineticField(models.TextField):
    description = "Kinetic field for graphic widget"

    def __init__(self, *args, **kwargs):
        defaults = {
            'help_text': 'Graphic widget',
            'default': '',
            # 'max_length': 1000,
        }
        defaults.update(kwargs)
        return super(KineticField, self).__init__(*args, **defaults)

    def formfield(self, **kwargs):
        defaults = {'form_class': KineticFormField}
        # defaults = {'widget': KineticWidget}
        defaults.update(kwargs)
        return super(KineticField, self).formfield(**defaults)



# TODO: delete these models (below). They are just for testing purposes.

def get_default_JSON():
	""" iba pre testovacie ucely """
	import urllib2
	response = urllib2.urlopen('http://team28-12.ucebne.fiit.stuba.sk/~kachman/value.json')
	json_data = response.read()
	# json_data = "<Test JSON>"
	# print(json_data)
	return str(json_data)

class TestWidgetSimple(models.Model):
	jeden = KineticField(default=get_default_JSON)  # TODO: bug v Djangu? (ked dam callable, tak to da ten input element dva krat za sebou!!!) # update: to nie je bug, ono dava vzdy druhe pole (hiddne) s defaultnou hodnotou - ktora bola na zaciatku - asi kvoli nejakym js-enabled widgetom, ktore umoznouju "undo" alebo nieco take

	class Meta:
	    verbose_name = 'Single Widget test'
	    verbose_name_plural = 'Single Widget tests'


{'fraction_non_alphanumeric': 0.10750243585579734, 'fraction_numerical': 0.006495615459564794, 'mean_word_length': 3.753086419753086, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3273780', 'n_tokens_mistral': 1004, 'n_tokens_neox': 939, 'n_words': 261}