Skip to content

Commit a08582a

Browse files
authored
* #1641, #1642 & #1559 - #1641 - removed character limitation for work_statuses.description & work_issues.description - #1642 - Updated existing staff entries email to lower case - Refactored code to set email to lower case when adding/updating staffs - #1559 - Fixed the issue where task template upload was failing when `tips` column was empty * lint fixes * moved lower case conversion to schema for staff validation and existance check APIs * remove #1641 related changes * revert workplan issues form & status form to include character limits * re-added validation rule to WorkStatusParameterSchema * merge migrations * resolved conflicts, added `email` in data check * lint fix
1 parent 8a6fac4 commit a08582a

File tree

11 files changed

+545
-461
lines changed

11 files changed

+545
-461
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""Convert staff emails to lower case
2+
3+
Revision ID: 097d41841ba4
4+
Revises: 65cb91595d6a
5+
Create Date: 2024-01-11 14:04:10.156478
6+
7+
"""
8+
import sqlalchemy as sa
9+
from alembic import op
10+
from sqlalchemy.sql import column, table
11+
12+
13+
# revision identifiers, used by Alembic.
14+
revision = '097d41841ba4'
15+
down_revision = '65cb91595d6a'
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
# ### commands auto generated by Alembic - please adjust! ###
22+
conn = op.get_bind()
23+
staff_table = table('staffs',
24+
column('id', sa.Integer),
25+
column('name', sa.String),
26+
column('phone',sa.String),
27+
column('email', sa.String),
28+
column('is_active', sa.Boolean),
29+
column('position_id', sa.Integer)
30+
)
31+
32+
conn.execute(
33+
staff_table.update()\
34+
.values(email=sa.func.lower(staff_table.c.email))
35+
)
36+
37+
# ### end Alembic commands ###
38+
39+
40+
def downgrade():
41+
# ### commands auto generated by Alembic - please adjust! ###
42+
pass
43+
# ### end Alembic commands ###
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""merging 097d41841ba4 and 09a79ca8e8fd
2+
3+
Revision ID: 52b37bc04925
4+
Revises: 097d41841ba4, 09a79ca8e8fd
5+
Create Date: 2024-01-15 10:02:26.499111
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '52b37bc04925'
14+
down_revision = ('097d41841ba4', '09a79ca8e8fd')
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
pass
21+
22+
23+
def downgrade():
24+
pass

epictrack-api/src/api/models/work_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""Model to handle all operations related to WorkStatus."""
1515
from __future__ import annotations
1616

17-
from typing import List, Dict
17+
from typing import Dict, List
1818

1919
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String, desc
2020
from sqlalchemy.orm import relationship

epictrack-api/src/api/schemas/request/staff_request.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
"""Staff resource's input validations"""
15-
from marshmallow import fields, validate
15+
from marshmallow import fields, pre_load, validate
1616

1717
from api.schemas.validators import Phone
1818

@@ -47,6 +47,14 @@ class StaffExistanceQueryParamSchema(RequestQueryParameterSchema):
4747
missing=None,
4848
)
4949

50+
@pre_load
51+
def convert_email_to_lower(self, data, **kwargs): # pylint: disable=unused-argument
52+
"""Converts staff email into lower case string"""
53+
data = dict(data)
54+
if "email" in data:
55+
data["email"] = data["email"].lower()
56+
return data
57+
5058

5159
class StaffByPositionsQueryParamSchema(BasicRequestQueryParameterSchema):
5260
"""Staff by positions query parameter"""
@@ -88,10 +96,16 @@ class StaffBodyParameterSchema(RequestBodyParameterSchema):
8896
)
8997

9098
is_active = fields.Boolean(
91-
metadata={"description": "Active status of the staff"},
92-
required=True
99+
metadata={"description": "Active status of the staff"}, required=True
93100
)
94101

102+
@pre_load
103+
def convert_email_to_lower(self, data, **kwargs): # pylint: disable=unused-argument
104+
"""Converts staff email into lower case string"""
105+
if "email" in data:
106+
data["email"] = data["email"].lower()
107+
return data
108+
95109

96110
class StaffEmailPathParameterSchema(RequestPathParameterSchema):
97111
"""Staff email path parameter schema"""
@@ -101,3 +115,11 @@ class StaffEmailPathParameterSchema(RequestPathParameterSchema):
101115
validate=validate.Email(),
102116
required=True,
103117
)
118+
119+
@pre_load
120+
def convert_email_to_lower(self, data, **kwargs): # pylint: disable=unused-argument
121+
"""Converts staff email into lower case string"""
122+
data = dict(data)
123+
if "email" in data:
124+
data["email"] = data["email"].lower()
125+
return data

epictrack-api/src/api/schemas/request/task_request.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ class TaskBodyParameterSchema(RequestBodyParameterSchema):
8787

8888
tips = fields.Str(
8989
metadata={"description": "Practical info on why/how to do the task"},
90-
# validate=validate.Length(max=150),
91-
required=True,
90+
allow_none=True
9291
)
9392

9493
number_of_days = fields.Int(

0 commit comments

Comments
 (0)