Skip to content

Commit

Permalink
use setuptools-scm
Browse files Browse the repository at this point in the history
  • Loading branch information
yaghoubi committed Sep 30, 2024
1 parent 362d594 commit 622989a
Show file tree
Hide file tree
Showing 383 changed files with 57,742 additions and 699 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: pip install build

- name: Build package
run: python setup.py sdist bdist_wheel
run: python -m build

- name: Publish to PyPI
env:
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include django_daisy/_version.py
include README.md
recursive-include django_daisy *
global-exclude *.pyc
Empty file added build/lib/fields/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions build/lib/fields/checkbox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django import forms
from django.db import models


class CheckBoxModelField(models.CharField):
def formfield(self, **kwargs):
return forms.ChoiceField(
choices=self.choices,
widget=forms.RadioSelect,
label=self.verbose_name,
)
36 changes: 36 additions & 0 deletions build/lib/fields/ckeditor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from django import forms
from django.db import models


class CkeditorWidget(forms.Textarea):
class Media:
js = (
'admin/fields/ckeditor_init.js',
)


class CkeditorField(models.TextField):

def __init__(self, *args, column_type='mediumtext', inline=False, **kwargs):
# specifies column type choices are text | mediumtext | longtext
# default is mediumtext
self.column_type = column_type
self.inline = inline
super().__init__(*args, **kwargs)

def formfield(self, **kwargs):
_class = "ckeditor-field" if self.inline else "ckeditor-field"
kwargs['widget'] = CkeditorWidget(attrs={'class': _class})
return super().formfield(**{
'max_length': self.max_length,
**({} if self.choices is not None else {'widget': forms.Textarea}),
**kwargs,
})

def db_type(self, connection):
if connection.settings_dict['ENGINE'] == 'django.db.backends.mysql':
return self.column_type
elif connection.settings_dict['ENGINE'] == 'django.db.backends.postgresql':
return 'text'

return super().db_type(connection)
36 changes: 36 additions & 0 deletions build/lib/fields/comma_sep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from django.db.models import CharField
from django.forms import fields


class CommaSepWidget(fields.TextInput):
"""
tokenfield tags field widget
"""
template_name = 'django/forms/widgets/comma_seperate.html'

class Media:
js = (
'admin/panel/global_assets/js/plugins/forms/tags/tokenfield.min.js',
)

def __init__(self, attrs=None):
default_attrs = {
'class': 'tokenfield',
}
if attrs:
default_attrs.update(attrs)
super().__init__(default_attrs)


class CommaSepModelField(CharField):
description = "keyword field with comma separate in CharField"

def __init__(self, *args, db_collation=None, **kwargs):
kwargs['max_length'] = 255
super().__init__(*args, **kwargs)

def formfield(self, **kwargs):
# override widget field
defaults = {'widget': CommaSepWidget}

return super().formfield(**defaults)
33 changes: 33 additions & 0 deletions build/lib/fields/keyvalue_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from django.db import models
from django import forms
from django.forms.widgets import Textarea


class JsonKeyValueWidget(Textarea):
template_name = 'django/forms/widgets/keyvalue_field.html'

def __init__(self, attrs={}):
attrs['class'] = 'keyvalue-json-editor-field'
super().__init__(attrs)

class Media:
js = (
'admin/fields/keyvalue_field/script.js',
)
css = {
'all': (
'admin/fields/keyvalue_field/style.css',
)
}


class JsonKeyValueField(models.JSONField):
description = "custom json key value field"

def formfield(self, **kwargs):
return super().formfield(**{
'widget': JsonKeyValueWidget,
'encoder': self.encoder,
'decoder': self.decoder,
**kwargs,
})
27 changes: 27 additions & 0 deletions build/lib/fields/summernote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from django.db import models
from django import forms


class SummernoteField(models.TextField):

def __init__(self, *args, column_type='mediumtext', **kwargs):
# specifies column type choices are text | mediumtext | longtext
# default is mediumtext
self.column_type = column_type
super(SummernoteField, self).__init__(*args, **kwargs)

def formfield(self, **kwargs):
kwargs['widget'] = forms.Textarea(attrs={'class': 'summernote'})
return super().formfield(**{
'max_length': self.max_length,
**({} if self.choices is not None else {'widget': forms.Textarea}),
**kwargs,
})

def db_type(self, connection):
if connection.settings_dict['ENGINE'] == 'django.db.backends.mysql':
return self.column_type
elif connection.settings_dict['ENGINE'] == 'django.db.backends.postgresql':
return 'text'

return super(SummernoteField, self).db_type(connection)
45 changes: 45 additions & 0 deletions build/lib/fields/thousand_sep_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from django.db.models import PositiveBigIntegerField
from django.forms import fields


class ThousandSepWidget(fields.TextInput):
template_name = 'django/forms/widgets/thousand_sep.html'

def format_value(self, value):
# Format the value with thousand separators
# e.g., 200000 => '200,000'
return '{:,}'.format(int(value)) if value else None

def value_from_datadict(self, data, files, name):
if value := super().value_from_datadict(data, files, name):
return value.replace(',', '')
return ''

class Media:
js = (
'admin/fields/thousand_sep_field.js',
)


class ThousandSepField(PositiveBigIntegerField):
description = "number field with thousand separate eg: 200,000"

def formfield(self, **kwargs):
return super().formfield(**{
'widget': ThousandSepWidget,
})

# def from_db_value(self, value, expression, connection):
# if value is None:
# return value
# return locale.format_string("%d", value, grouping=True)

def get_prep_value(self, value):
# Convert formatted value back to integer for storage
if isinstance(value, str):
value = value.replace(',', '')
return super().get_prep_value(value)

def value_to_string(self, obj):
value = self.value_from_object(obj)
return self.to_python(value)
36 changes: 36 additions & 0 deletions build/lib/fields/tinyeditor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from django import forms
from django.db import models


class TinyWidget(forms.Textarea):
class Media:
js = (
'admin/fields/tiny_init.js',
)


class TinyEditorField(models.TextField):

def __init__(self, *args, column_type='mediumtext', inline=False, **kwargs):
# specifies column type choices are text | mediumtext | longtext
# default is mediumtext
self.column_type = column_type
self.inline = inline
super().__init__(*args, **kwargs)

def formfield(self, **kwargs):
_class = "editor-field" if not self.inline else "editor-inline-field"
kwargs['widget'] = TinyWidget(attrs={'class': _class})
return super().formfield(**{
'max_length': self.max_length,
**({} if self.choices is not None else {'widget': forms.Textarea}),
**kwargs,
})

def db_type(self, connection):
if connection.settings_dict['ENGINE'] == 'django.db.backends.mysql':
return self.column_type
elif connection.settings_dict['ENGINE'] == 'django.db.backends.postgresql':
return 'text'

return super().db_type(connection)
Binary file added build/lib/locale/fa/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 622989a

Please sign in to comment.