Commit c859122b authored by Philip ABBET's avatar Philip ABBET
Browse files

[algorithms] Bugfix: Can't use the admin interface for binary algorithms

parent b0d3d276
......@@ -90,6 +90,13 @@ class AlgorithmModelForm(forms.ModelForm):
),
}
def __init__(self, *args, **kwargs):
super(AlgorithmModelForm, self).__init__(*args, **kwargs)
if kwargs['instance'].is_binary():
del self.fields['source_code_file']
def clean_declaration_file(self):
"""Cleans-up the file data, make sure it is really new"""
......@@ -231,4 +238,12 @@ class Algorithm(admin.ModelAdmin):
),
)
def get_form(self, request, obj=None, **kwargs):
if obj.is_binary():
self.exclude = ('source_code_file',)
fieldsets = filter(lambda x: x[0] == 'Definition',self.fieldsets)[0]
fieldsets[1]['fields'] = ('hash', 'splittable', 'declaration_file', 'language')
form = super(Algorithm, self).get_form(request, obj, **kwargs)
return form
admin.site.register(AlgorithmModel, Algorithm)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment