Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1642 & #1559 #1647

Merged
merged 11 commits into from
Jan 17, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Convert staff emails to lower case

Revision ID: 097d41841ba4
Revises: 65cb91595d6a
Create Date: 2024-01-11 14:04:10.156478

"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.sql import column, table


# revision identifiers, used by Alembic.
revision = '097d41841ba4'
down_revision = '65cb91595d6a'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
conn = op.get_bind()
staff_table = table('staffs',
column('id', sa.Integer),
column('name', sa.String),
column('phone',sa.String),
column('email', sa.String),
column('is_active', sa.Boolean),
column('position_id', sa.Integer)
)

conn.execute(
staff_table.update()\
.values(email=sa.func.lower(staff_table.c.email))
)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""merging 097d41841ba4 and 09a79ca8e8fd

Revision ID: 52b37bc04925
Revises: 097d41841ba4, 09a79ca8e8fd
Create Date: 2024-01-15 10:02:26.499111

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '52b37bc04925'
down_revision = ('097d41841ba4', '09a79ca8e8fd')
branch_labels = None
depends_on = None


def upgrade():
pass


def downgrade():
pass
2 changes: 1 addition & 1 deletion epictrack-api/src/api/models/work_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""Model to handle all operations related to WorkStatus."""
from __future__ import annotations

from typing import List, Dict
from typing import Dict, List

from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String, desc
from sqlalchemy.orm import relationship
Expand Down
25 changes: 22 additions & 3 deletions epictrack-api/src/api/schemas/request/staff_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Staff resource's input validations"""
from marshmallow import fields, validate
from marshmallow import fields, pre_load, validate

from api.schemas.validators import Phone

Expand Down Expand Up @@ -47,6 +47,13 @@ class StaffExistanceQueryParamSchema(RequestQueryParameterSchema):
missing=None,
)

@pre_load
def convert_email_to_lower(self, data, **kwargs): # pylint: disable=unused-argument
"""Converts staff email into lower case string"""
data = dict(data)
data["email"] = data["email"].lower()
return data


class StaffByPositionsQueryParamSchema(BasicRequestQueryParameterSchema):
"""Staff by positions query parameter"""
Expand Down Expand Up @@ -88,10 +95,15 @@ class StaffBodyParameterSchema(RequestBodyParameterSchema):
)

is_active = fields.Boolean(
metadata={"description": "Active status of the staff"},
required=True
metadata={"description": "Active status of the staff"}, required=True
)

@pre_load
def convert_email_to_lower(self, data, **kwargs): # pylint: disable=unused-argument
"""Converts staff email into lower case string"""
data["email"] = data["email"].lower()
return data
salabh-aot marked this conversation as resolved.
Show resolved Hide resolved


class StaffEmailPathParameterSchema(RequestPathParameterSchema):
"""Staff email path parameter schema"""
Expand All @@ -101,3 +113,10 @@ class StaffEmailPathParameterSchema(RequestPathParameterSchema):
validate=validate.Email(),
required=True,
)

@pre_load
def convert_email_to_lower(self, data, **kwargs): # pylint: disable=unused-argument
"""Converts staff email into lower case string"""
data = dict(data)
data["email"] = data["email"].lower()
return data
3 changes: 1 addition & 2 deletions epictrack-api/src/api/schemas/request/task_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ class TaskBodyParameterSchema(RequestBodyParameterSchema):

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

number_of_days = fields.Int(
Expand Down
22 changes: 10 additions & 12 deletions epictrack-api/src/api/schemas/request/work_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class WorkTypeIdQueryParamSchema(RequestQueryParameterSchema):
metadata={"description": "The id of the work type"},
validate=validate.Range(min=1),
load_default=None,
allow_none=True
allow_none=True,
)


Expand All @@ -197,8 +197,7 @@ class WorkStatusParameterSchema(RequestBodyParameterSchema):
)

notes = fields.Str(
metadata={"description": "Notes for the work status "},
allow_none=True
metadata={"description": "Notes for the work status "}, allow_none=True
)

posted_date = fields.DateTime(
Expand Down Expand Up @@ -230,7 +229,8 @@ class WorkIssuesParameterSchema(RequestBodyParameterSchema):
)

expected_resolution_date = fields.DateTime(
metadata={"description": "Expected Resolution date for the issue"}, required=False
metadata={"description": "Expected Resolution date for the issue"},
required=False,
)

updates = fields.List(
Expand All @@ -252,15 +252,11 @@ class WorkIssuesUpdateSchema(WorkIssuesParameterSchema):
updates = fields.List(
fields.Dict(
description=fields.Str(
metadata={"description": "Description of the update"},
required=True
),
id=fields.Int(
metadata={"description": "ID of the update"},
required=True
metadata={"description": "Description of the update"}, required=True
),
id=fields.Int(metadata={"description": "ID of the update"}, required=True),
metadata={"description": "List of updates for the issue with IDs"},
required=True
required=True,
),
metadata={"description": "List of updates for the issue with IDs"},
required=False,
Expand All @@ -278,6 +274,8 @@ class WorkNotesBodySchema(RequestBodyParameterSchema):

note_type = fields.Str(
metadata={"description": "Type of work status notes"},
validate=validate.OneOf(['status_notes', 'issue_notes']), # Add your predefined types
validate=validate.OneOf(
["status_notes", "issue_notes"]
), # Add your predefined types
required=True,
)
1 change: 1 addition & 0 deletions epictrack-api/src/api/services/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def import_staffs(cls, file: IO):
username = TokenInfo.get_username()
data["created_by"] = username
data = data.to_dict("records")
data["email"] = data["email"].lower()
db.session.bulk_insert_mappings(Staff, data)
db.session.commit()
return "Inserted successfully"
Expand Down
3 changes: 3 additions & 0 deletions epictrack-api/src/api/services/task_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""Service to manage Task Templates."""
from typing import IO, List

import numpy as np
import pandas as pd
from flask import current_app
from sqlalchemy.sql import exists
Expand Down Expand Up @@ -47,6 +48,8 @@ def create_task_template(cls, data: dict, template_file: IO) -> TaskTemplate:
{"responsibility_id": res.id},
regex=True,
)
task_data = task_data.replace({np.nan: None})
task_data = task_data.replace({np.NaN: None})
tasks = task_data.to_dict("records")
cls.create_bulk_tasks(tasks)
TaskTemplate.commit()
Expand Down
10 changes: 7 additions & 3 deletions epictrack-web/src/components/workPlan/issues/IssuesForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import * as yup from "yup";
import { yupResolver } from "@hookform/resolvers/yup";
import { Box, FormControlLabel, Grid, Stack, Tooltip } from "@mui/material";
import ControlledTextField from "../../shared/controlledInputComponents/ControlledTextField";
import { ETFormLabelWithCharacterLimit, ETParagraph } from "../../shared";
import {
ETFormLabel,
ETFormLabelWithCharacterLimit,
ETParagraph,
} from "../../shared";
import ControlledSwitch from "../../shared/controlledInputComponents/ControlledSwitch";
import { IssuesContext } from "./IssuesContext";
import { IconProps } from "../../icons/type";
Expand Down Expand Up @@ -151,11 +155,11 @@ const IssuesForm = () => {
name="description"
fullWidth
size="small"
multiline
rows={4}
inputProps={{
maxLength: descriptionCharacterLimit,
}}
multiline
rows={4}
/>
</Grid>
<Grid item xs={12}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const schema = yup.object().shape({
posted_date: yup.string().required("Date is required"),
description: yup.string().required("Description is required"),
});

const CHARACTER_LIMIT = 500;

const StatusForm = () => {
Expand Down
Loading