diff options
author | Andrey Mekin <anmekin@gmail.com> | 2016-07-20 18:35:18 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-20 18:35:18 +0600 |
commit | 9de0cc64232b9d0936e8198ba470d83c4b849826 (patch) | |
tree | c8c1a878ff6a80f57887ca2123f385ffdb1d3498 | |
parent | 3e096941a0d31aa89541e47d471d83cbe8a5a439 (diff) | |
parent | 97a754b95de22023d68fe01820d5cbdb0e201755 (diff) | |
download | omaha-server-9de0cc64232b9d0936e8198ba470d83c4b849826.zip omaha-server-9de0cc64232b9d0936e8198ba470d83c4b849826.tar.gz omaha-server-9de0cc64232b9d0936e8198ba470d83c4b849826.tar.bz2 |
Merge pull request #204 from anmekin/fix/version_field
Override display_for_field for VersoinField
-rw-r--r-- | omaha_server/omaha/admin.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/omaha_server/omaha/admin.py b/omaha_server/omaha/admin.py index b3c7ffc..8519567 100644 --- a/omaha_server/omaha/admin.py +++ b/omaha_server/omaha/admin.py @@ -17,11 +17,18 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ +import copy from django.contrib import admin +from django.contrib.admin import utils +from django.utils.encoding import smart_text + +from dynamic_preferences.models import GlobalPreferenceModel, UserPreferenceModel +from versionfield import VersionField + from omaha.models import Channel, Platform, Application, Version, Action, PartialUpdate, Data from omaha.forms import ApplicationAdminForm, VersionAdminForm, ActionAdminForm, DataAdminForm -from dynamic_preferences.models import GlobalPreferenceModel, UserPreferenceModel + admin.site.unregister(GlobalPreferenceModel) admin.site.unregister(UserPreferenceModel) @@ -68,3 +75,12 @@ class VersionAdmin(admin.ModelAdmin): list_filter = ('channel__name', 'platform__name', 'app__name',) readonly_fields = ('file_hash',) form = VersionAdminForm + + +def my_display_for_field(value, field, *args, **kwargs): + if isinstance(field, VersionField): + return smart_text(value) + return django_display_for_field(value, field, *args, **kwargs) + +django_display_for_field = copy.deepcopy(utils.display_for_field) +utils.display_for_field = my_display_for_field
\ No newline at end of file |