Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1883)

Unified Diff: appengine/findit/model/versioned_config.py

Issue 2488113005: [Findit] Re-org code. (Closed)
Patch Set: Rebase. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/model/test/versioned_model_test.py ('k') | appengine/findit/model/versioned_model.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/model/versioned_config.py
diff --git a/appengine/findit/model/versioned_config.py b/appengine/findit/model/versioned_config.py
deleted file mode 100644
index 02f2f4f07060eac698e4e484ee23eb04ef054e97..0000000000000000000000000000000000000000
--- a/appengine/findit/model/versioned_config.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright 2015 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Versioned singleton entity with the global configuration."""
-
-import logging
-
-from google.appengine.ext import ndb
-
-from model.versioned_model import VersionedModel
-
-
-class VersionedConfig(VersionedModel):
- """Singleton entity with the global configuration of the service.
-
- All changes are stored in the revision log.
- """
-
- # When this revision of configuration was created.
- updated_ts = ndb.DateTimeProperty(indexed=False, auto_now=True)
-
- # Who created this revision of configuration.
- updated_by = ndb.StringProperty(indexed=False)
-
- @classmethod
- def Get(cls, version=None):
- """Returns the version of the config entity, the latest if not specified."""
- config_data = cls.GetVersion(version=version)
- return config_data or cls() if version is None else config_data
-
- def Update(self, user, is_admin, **kwargs):
- """Apply ``kwargs`` dict to the entity and stores the entity if changed."""
- if not is_admin:
- raise Exception('Only admin could update config.')
-
- dirty = False
- for k, v in kwargs.iteritems():
- assert k in self._properties, k
- if getattr(self, k) != v:
- setattr(self, k, v)
- dirty = True
-
- if dirty:
- user_name = user.email().split('@')[0]
- self.updated_by = user_name
- self.Save()
- logging.info('Config %s was updated by %s', self.__class__, user_name)
-
- return dirty
« no previous file with comments | « appengine/findit/model/test/versioned_model_test.py ('k') | appengine/findit/model/versioned_model.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698