Make auto-user fields non-auto. (#1310)

This commit is contained in:
Jason Robbins 2021-05-06 18:12:39 -07:00 коммит произвёл GitHub
Родитель 248c2c13fd
Коммит d92661ffa2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 17 добавлений и 9 удалений

Просмотреть файл

@ -939,6 +939,8 @@ class Feature(DictModel):
# Diff values to see what properties have changed.
changed_props = []
for prop_name, prop in self.properties().iteritems():
if prop_name in ('created_by', 'updated_by'):
continue
new_val = getattr(self, prop_name, None)
old_val = getattr(self, '_old_' + prop_name, None)
if new_val != old_val:
@ -972,8 +974,8 @@ class Feature(DictModel):
# Metadata.
created = db.DateTimeProperty(auto_now_add=True)
updated = db.DateTimeProperty(auto_now=True)
updated_by = db.UserProperty(auto_current_user=True)
created_by = db.UserProperty(auto_current_user_add=True)
updated_by = db.UserProperty()
created_by = db.UserProperty()
# General info.
category = db.IntegerProperty(required=True)

Просмотреть файл

@ -26,7 +26,8 @@ import werkzeug.exceptions # Flask HTTP stuff.
from google.appengine.ext import db
from google.appengine.api import mail
# from google.appengine.api import users
# TODO(jrobbins): phase out gae_users.
from google.appengine.api import users as gae_users
from framework import users
from internals import models
@ -40,8 +41,8 @@ class EmailFormattingTest(unittest.TestCase):
self.feature_1 = models.Feature(
name='feature one', summary='sum', category=1, visibility=1,
standardization=1, web_dev_views=1, impl_status_chrome=1,
created_by=users.User(email='creator@example.com'),
updated_by=users.User(email='editor@example.com'),
created_by=gae_users.User(email='creator@example.com'),
updated_by=gae_users.User(email='editor@example.com'),
blink_components=['Blink'])
self.feature_1.put()
self.component_1 = models.BlinkComponent(name='Blink')
@ -59,8 +60,8 @@ class EmailFormattingTest(unittest.TestCase):
self.feature_2 = models.Feature(
name='feature two', summary='sum', category=1, visibility=1,
standardization=1, web_dev_views=1, impl_status_chrome=1,
created_by=users.User(email='creator@example.com'),
updated_by=users.User(email='editor@example.com'),
created_by=gae_users.User(email='creator@example.com'),
updated_by=gae_users.User(email='editor@example.com'),
blink_components=['Blink'])
self.feature_2.put()

Просмотреть файл

@ -27,7 +27,8 @@ from django import forms
# Appengine imports.
from framework import ramcache
# from google.appengine.api import users
# TODO(jrobbins): phase out gae_users
from google.appengine.api import users as gae_users
from framework import users
from google.appengine.ext import db
@ -132,6 +133,7 @@ class FeatureNew(basehandlers.FlaskHandler):
# TODO(jrobbins): Validate input, even though it is done on client.
feature_type = int(self.form.get('feature_type', 0))
gae_user = gae_users.User(email=self.get_current_user().email())
feature = models.Feature(
category=int(self.form.get('category')),
name=self.form.get('name'),
@ -144,7 +146,9 @@ class FeatureNew(basehandlers.FlaskHandler):
unlisted=self.form.get('unlisted') == 'on',
web_dev_views=models.DEV_NO_SIGNALS,
blink_components=blink_components,
tag_review_status=processes.initial_tag_review_status(feature_type))
tag_review_status=processes.initial_tag_review_status(feature_type),
created_by=gae_user,
updated_by=gae_user)
key = feature.put()
# TODO(jrobbins): enumerate and remove only the relevant keys.
@ -497,6 +501,7 @@ class FeatureEditStage(basehandlers.FlaskHandler):
if self.touched('ongoing_constraints'):
feature.ongoing_constraints = self.form.get('ongoing_constraints')
feature.updated_by = gae_users.User(email=self.get_current_user().email())
key = feature.put()
# TODO(jrobbins): enumerate and remove only the relevant keys.