Browse Source

tasks username

walle 6 years ago
parent
commit
c0e8f7ae18
3 changed files with 27 additions and 1 deletions
  1. 24 0
      migrations/versions/91c4d13540c3_task_username.py
  2. 1 0
      walle/form/task.py
  3. 2 1
      walle/model/task.py

+ 24 - 0
migrations/versions/91c4d13540c3_task_username.py

@@ -0,0 +1,24 @@
+"""task_username
+
+Revision ID: 91c4d13540c3
+Revises: 9532a372b5aa
+Create Date: 2018-12-25 15:19:15.045063
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '91c4d13540c3'
+down_revision = '9532a372b5aa'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    op.add_column('tasks', sa.Column('user_name', sa.String(100), nullable=True))
+
+
+def downgrade():
+    op.drop_column('tasks', 'user_name')

+ 1 - 0
walle/form/task.py

@@ -42,6 +42,7 @@ class TaskForm(Form):
             'name': self.name.data if self.name.data else '',
             # todo
             'user_id': current_user.id,
+            'user_name': current_user.username,
             'project_id': self.project_id.data,
             # todo default value
             'action': 0,

+ 2 - 1
walle/model/task.py

@@ -40,6 +40,7 @@ class TaskModel(SurrogatePK, Model):
     id = db.Column(Integer, primary_key=True, autoincrement=True)
     name = db.Column(String(100))
     user_id = db.Column(Integer)
+    user_name = db.Column(String(10))
     project_id = db.Column(Integer)
     action = db.Column(Integer)
     status = db.Column(Integer)
@@ -166,8 +167,8 @@ class TaskModel(SurrogatePK, Model):
         item = {
             'id': self.id,
             'name': self.name,
-            'user_name': self.name,
             'user_id': int(self.user_id),
+            'user_name': self.user_name,
             'project_id': int(self.project_id),
             'project_name': self.project_id if self.project_id else '',
             'action': self.action,