saxix / django-adminactions
Showing 7 of 30 files from the diff.

@@ -58,16 +58,4 @@
Loading
58 58
59 59
    header = forms.BooleanField(label=_('Header'), required=False)
60 60
    use_display = forms.BooleanField(label=_('Use display'), required=False)
61 -
    # delimiter = forms.ChoiceField(choices=zip(delimiters, delimiters), initial=',')
62 -
    # quotechar = forms.ChoiceField(choices=zip(quotes, quotes), initial="'")
63 -
    # quoting = forms.ChoiceField(
64 -
    #     choices=((csv.QUOTE_ALL, 'All'),
65 -
    #              (csv.QUOTE_MINIMAL, 'Minimal'),
66 -
    #              (csv.QUOTE_NONE, 'None'),
67 -
    #              (csv.QUOTE_NONNUMERIC, 'Non Numeric')), initial=csv.QUOTE_ALL)
68 -
    #
69 -
    # escapechar = forms.ChoiceField(choices=(('', ''), ('\\', '\\')), required=False)
70 -
    # datetime_format = forms.CharField(initial=formats.get_format('DATETIME_FORMAT'))
71 -
    # date_format = forms.CharField(initial=formats.get_format('DATE_FORMAT'))
72 -
    # time_format = forms.CharField(initial=formats.get_format('TIME_FORMAT'))
73 61
    columns = forms.MultipleChoiceField(label=_('Columns'), widget=SelectMultiple(attrs={'size': 20}))

@@ -134,10 +134,6 @@
Loading
134 134
    if isinstance(value, models.Model):
135 135
        return smart_str(value)
136 136
137 -
    # if isinstance(obj, Model):
138 -
    #     field = get_field_by_path(obj, fieldname)
139 -
    #     if isinstance(field, ForeignKey):
140 -
    #         return unicode(value)
141 137
    if isinstance(value, str):
142 138
        value = smart_str(value)
143 139

@@ -85,21 +85,19 @@
Loading
85 85
86 86
87 87
OPERATIONS = OperationManager({
88 -
    df.CharField: [('upper', (str.upper, False, True, "convert to uppercase")),
89 -
                   ('lower', (str.lower, False, True, "convert to lowercase")),
90 -
                   ('capitalize', (str.capitalize, False, True, "capitalize first character")),
91 -
                   # ('capwords', (string.capwords, False, True, "capitalize each word")),
92 -
                   # ('swapcase', (string.swapcase, False, True, "")),
93 -
                   ('trim', (str.strip, False, True, "leading and trailing whitespace"))],
94 -
    df.IntegerField: [('add percent', (add_percent, True, True, "add <arg> percent to existing value")),
88 +
    df.CharField: [('upper', (str.upper, False, True, _("convert to uppercase"))),
89 +
                   ('lower', (str.lower, False, True, _("convert to lowercase"))),
90 +
                   ('capitalize', (str.capitalize, False, True, _("capitalize first character"))),
91 +
                   ('trim', (str.strip, False, True, _("leading and trailing whitespace")))],
92 +
    df.IntegerField: [('add percent', (add_percent, True, True, _("add <arg> percent to existing value"))),
95 93
                      ('sub percent', (sub_percent, True, True, "")),
96 94
                      ('sub', (sub_percent, True, True, "")),
97 95
                      ('add', (add, True, True, ""))],
98 96
    df.BooleanField: [('swap', (negate, False, True, ""))],
99 97
    df.NullBooleanField: [('swap', (negate, False, True, ""))],
100 98
    df.EmailField: [('change domain', (change_domain, True, True, "")),
101 -
                    ('upper', (str.upper, False, True, "convert to uppercase")),
102 -
                    ('lower', (str.lower, False, True, "convert to lowercase"))],
99 +
                    ('upper', (str.upper, False, True, _("convert to uppercase"))),
100 +
                    ('lower', (str.lower, False, True, _("convert to lowercase")))],
103 101
    df.URLField: [('change protocol', (change_protocol, True, True, ""))]
104 102
})
105 103
@@ -107,15 +105,10 @@
Loading
107 105
class MassUpdateForm(GenericActionForm):
108 106
    _clean = forms.BooleanField(label='clean()',
109 107
                                required=False,
110 -
                                help_text="if checked calls obj.clean()")
108 +
                                help_text=_("if checked calls obj.clean()"))
111 109
112 110
    _validate = forms.BooleanField(label='Validate',
113 -
                                   help_text="if checked use obj.save() instead of manager.update()")
114 -
115 -
    # _unique_transaction = forms.BooleanField(label='Unique transaction',
116 -
    # required=False,
117 -
    # help_text="If checked create one transaction for the whole update. "
118 -
    # "If any record cannot be updated everything will be rolled-back")
111 +
                                   help_text=_("if checked use obj.save() instead of manager.update()"))
119 112
120 113
    def __init__(self, *args, **kwargs):
121 114
        super().__init__(*args, **kwargs)
@@ -155,7 +148,6 @@
Loading
155 148
                    enabler = 'chk_id_%s' % name
156 149
                    function = self.data.get('func_id_%s' % name, False)
157 150
                    if self.data.get(enabler, False):
158 -
                        # field_object, model, direct, m2m = self._meta.model._meta.get_field_by_name(name)
159 151
                        field_object, model, direct, m2m = get_field_by_name(self._meta.model, name)
160 152
                        value = field.clean(raw_value)
161 153
                        if function:
@@ -277,7 +269,7 @@
Loading
277 269
                                [f.name for f in modeladmin.model._meta.fields])
278 270
279 271
    if mass_update_fields and mass_update_exclude:
280 -
        raise Exception("Cannot set both 'mass_update_exclude' and 'mass_update_fields'")
272 +
        raise BaseException("Cannot set both 'mass_update_exclude' and 'mass_update_fields'")
281 273
    MForm = modelform_factory(modeladmin.model, form=mass_update_form,
282 274
                              exclude=mass_update_exclude,
283 275
                              fields=mass_update_fields,
@@ -314,10 +306,10 @@
Loading
314 306
                values = {}
315 307
                for field_name, value in list(form.cleaned_data.items()):
316 308
                    if isinstance(form.fields[field_name], ModelMultipleChoiceField):
317 -
                        messages.error(request, "Unable no mass update ManyToManyField without 'validate'")
309 +
                        messages.error(request, _("Unable no mass update ManyToManyField without 'validate'"))
318 310
                        return HttpResponseRedirect(request.get_full_path())
319 311
                    elif callable(value):
320 -
                        messages.error(request, "Unable no mass update using operators without 'validate'")
312 +
                        messages.error(request, _("Unable no mass update using operators without 'validate'"))
321 313
                        return HttpResponseRedirect(request.get_full_path())
322 314
                    elif field_name not in ['_selected_action', '_validate', 'select_across', 'action',
323 315
                                            '_unique_transaction', '_clean']:

@@ -30,12 +30,6 @@
Loading
30 30
    dependencies = forms.ChoiceField(label=_('Dependencies'),
31 31
                                     choices=((DEP_MOVE, _("Move")), (DEP_DELETE, _("Delete"))))
32 32
33 -
    # generic = forms.ChoiceField(label=_('Search GenericForeignKeys'),
34 -
    #                             help_text=_("Search for generic relation"),
35 -
    #                             choices=((GEN_IGNORE, _("No")),
36 -
    #                                      (GEN_RELATED, _("Only Related (look for Managers)")),
37 -
    #                                      (GEN_DEEP, _("Analyze Mode (very slow)"))))
38 -
39 33
    master_pk = forms.CharField(widget=HiddenInput)
40 34
    other_pk = forms.CharField(widget=HiddenInput)
41 35
    field_names = forms.CharField(required=False, widget=HiddenInput)
@@ -128,7 +122,6 @@
Loading
128 122
                return (False, merge_form, merge_kwargs)
129 123
130 124
    tpl = 'adminactions/merge.html'
131 -
    # transaction_supported = model_supports_transactions(modeladmin.model)
132 125
    ignored_fields = get_ignored_fields(queryset.model, "MERGE_ACTION_IGNORED_FIELDS")
133 126
134 127
    ctx = {

@@ -58,7 +58,6 @@
Loading
58 58
    if related == ALL_FIELDS:
59 59
        related = [rel.get_accessor_name()
60 60
                   for rel in utils.get_all_related_objects(master)]
61 -
    # for rel in master._meta.get_all_related_objects(False, False, False)]
62 61
63 62
    if m2m == ALL_FIELDS:
64 63
        m2m = set()
@@ -269,8 +268,6 @@
Loading
269 268
                    formats[i] = fmt
270 269
                except FieldDoesNotExist:
271 270
                    pass
272 -
                    # styles[i] = xlwt.easyxf(num_format_str=xls_options_default.get(col_class, 'general'))
273 -
                    # styles[i] = xls_options_default.get(col_class, 'general')
274 271
275 272
        return formats
276 273
@@ -393,20 +390,11 @@
Loading
393 390
                    formats[fieldname] = fmt
394 391
                except FieldDoesNotExist:
395 392
                    pass
396 -
                    # styles[i] = xlwt.easyxf(num_format_str=xls_options_default.get(col_class, 'general'))
397 -
                    # styles[i] = xls_options_default.get(col_class, 'general')
398 -
399 393
        return formats
400 394
401 395
    http_response = out is None
402 396
    if out is None:
403 -
        # if filename is None:
404 -
        # filename = filename or "%s.xls" % queryset.model._meta.verbose_name_plural.lower().replace(" ", "_")
405 -
        # response = HttpResponse(content_type='application/vnd.ms-excel')
406 -
        # response['Content-Disposition'] = 'attachment;filename="%s"' % filename.encode('us-ascii', 'replace')
407 397
        out = BytesIO()
408 -
        #
409 -
        # out = StringIO()
410 398
411 399
    config = xlsxwriter_options.copy()
412 400
    if options:

@@ -5,8 +5,5 @@
Loading
5 5
6 6
@register.tag
7 7
def url(parser, token):
8 -
    # try:
9 -
    #     from django.templatetags.future import url as _url
10 -
    # except:
11 8
    from django.template.defaulttags import url as _url
12 9
    return _url(parser, token)

@@ -29,8 +29,8 @@
Loading
29 29
             'select_across': BooleanField(initial='0', widget=HiddenInput, required=False),
30 30
             'app': CharField(initial=app_name, widget=HiddenInput),
31 31
             'model': CharField(initial=model_name, widget=HiddenInput),
32 -
             'graph_type': ChoiceField(label="Graph type", choices=graphs, required=True),
33 -
             'axes_x': ChoiceField(label="Group by and count by", choices=model_fields, required=True)}
32 +
             'graph_type': ChoiceField(label=_("Graph type"), choices=graphs, required=True),
33 +
             'axes_x': ChoiceField(label=_("Group by and count by"), choices=model_fields, required=True)}
34 34
35 35
    return DeclarativeFieldsMetaclass(str(class_name), (Form,), attrs)
36 36
@@ -124,7 +124,6 @@
Loading
124 124
                                     modeladmin=modeladmin,
125 125
                                     form=form)
126 126
    elif request.method == 'POST':
127 -
        # total = queryset.all().count()
128 127
        initial = {helpers.ACTION_CHECKBOX_NAME: request.POST.getlist(helpers.ACTION_CHECKBOX_NAME),
129 128
                   'select_across': request.POST.get('select_across', 0)}
130 129
        form = MForm(initial=initial)
Files Coverage
src/adminactions 84.84%
Project Totals (23 files) 84.84%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading