from app.model.db import DatabaseConnection
from flask import jsonify
import datetime
import json

cursor = DatabaseConnection().cursor

class RedFlag:

    # initialization
    def __init__(self, **kwargs):
        self.id = kwargs.get("id")
        self.casetype = kwargs.get("casetype")
        self.createdby = kwargs.get("createdby")
        self.location = kwargs.get("location")
        self.status = kwargs.get("status")
        self.comment = kwargs.get("comment")
        self.cursor = cursor

    # -------------------------------------------redflag-----------------------------------------------_
    def create_redflag(self, flag):
        self.cursor.execute("INSERT INTO redflag(casetype, createdby, location, comment, status)"
                            " VALUES(%s,%s,%s,%s, %s)", (flag.casetype, flag.createdby, flag.location,
                                                                flag.comment, flag.status
                                                                ))


    # gets all the incidents regardless of the casetype
    def get_all(self):
        self.cursor.execute("SELECT * FROM redflag")
        return self.cursor.fetchall()


    # gets a specific incident by id regardless of the casetype
    def get_one(self, id):
        self.cursor.execute("SELECT * FROM redflag WHERE id = %s", (id,))
        return self.cursor.fetchone()


    # deletes a specific incident regardless of the casetype
    def delete_one(self, id):
        self.cursor.execute("DELETE FROM redflag WHERE id = %s", (id,))


    # edits a comment of the incident regardless of the casetype 
    def patch_comment(self, id, comment):
        self.cursor.execute(f"UPDATE redflag SET comment = '{comment}' WHERE id = {id}")
        return True


    # edits a location of the incident regardless of the casetype
    def patch_location(self, id, location):
        self.cursor.execute(f"UPDATE redflag SET location='{location}' WHERE id = {id}")
        return True
    
# validation for the redflags
class ValidationRedFlags:

    def validate_redflag(self, createdby, casetype, location, status, comment):
        if not createdby and casetype and location and status and comment:
            return jsonify({"message": "No field should be left empty"})

  
       

       
4061f17751d116c6e1547e7f3e2832e02c205ea6
<mask token>


class RedFlag:
    <mask token>
    <mask token>

    def get_all(self):
        self.cursor.execute('SELECT * FROM redflag')
        return self.cursor.fetchall()
    <mask token>
    <mask token>
    <mask token>
    <mask token>


class ValidationRedFlags:

    def validate_redflag(self, createdby, casetype, location, status, comment):
        if not createdby and casetype and location and status and comment:
            return jsonify({'message': 'No field should be left empty'})

<mask token>


class RedFlag:

    def __init__(self, **kwargs):
        self.id = kwargs.get('id')
        self.casetype = kwargs.get('casetype')
        self.createdby = kwargs.get('createdby')
        self.location = kwargs.get('location')
        self.status = kwargs.get('status')
        self.comment = kwargs.get('comment')
        self.cursor = cursor
    <mask token>

    def get_all(self):
        self.cursor.execute('SELECT * FROM redflag')
        return self.cursor.fetchall()

    def get_one(self, id):
        self.cursor.execute('SELECT * FROM redflag WHERE id = %s', (id,))
        return self.cursor.fetchone()

    def delete_one(self, id):
        self.cursor.execute('DELETE FROM redflag WHERE id = %s', (id,))
    <mask token>

    def patch_location(self, id, location):
        self.cursor.execute(
            f"UPDATE redflag SET location='{location}' WHERE id = {id}")
        return True


class ValidationRedFlags:

    def validate_redflag(self, createdby, casetype, location, status, comment):
        if not createdby and casetype and location and status and comment:
            return jsonify({'message': 'No field should be left empty'})

<mask token>
cursor = DatabaseConnection().cursor


class RedFlag:

    def __init__(self, **kwargs):
        self.id = kwargs.get('id')
        self.casetype = kwargs.get('casetype')
        self.createdby = kwargs.get('createdby')
        self.location = kwargs.get('location')
        self.status = kwargs.get('status')
        self.comment = kwargs.get('comment')
        self.cursor = cursor

    def create_redflag(self, flag):
        self.cursor.execute(
            'INSERT INTO redflag(casetype, createdby, location, comment, status) VALUES(%s,%s,%s,%s, %s)'
            , (flag.casetype, flag.createdby, flag.location, flag.comment,
            flag.status))

    def get_all(self):
        self.cursor.execute('SELECT * FROM redflag')
        return self.cursor.fetchall()

    def get_one(self, id):
        self.cursor.execute('SELECT * FROM redflag WHERE id = %s', (id,))
        return self.cursor.fetchone()

    def delete_one(self, id):
        self.cursor.execute('DELETE FROM redflag WHERE id = %s', (id,))

    def patch_comment(self, id, comment):
        self.cursor.execute(
            f"UPDATE redflag SET comment = '{comment}' WHERE id = {id}")
        return True

    def patch_location(self, id, location):
        self.cursor.execute(
            f"UPDATE redflag SET location='{location}' WHERE id = {id}")
        return True


class ValidationRedFlags:

    def validate_redflag(self, createdby, casetype, location, status, comment):
        if not createdby and casetype and location and status and comment:
            return jsonify({'message': 'No field should be left empty'})

from app.model.db import DatabaseConnection
from flask import jsonify
import datetime
import json
cursor = DatabaseConnection().cursor


class RedFlag:

    def __init__(self, **kwargs):
        self.id = kwargs.get('id')
        self.casetype = kwargs.get('casetype')
        self.createdby = kwargs.get('createdby')
        self.location = kwargs.get('location')
        self.status = kwargs.get('status')
        self.comment = kwargs.get('comment')
        self.cursor = cursor

    def create_redflag(self, flag):
        self.cursor.execute(
            'INSERT INTO redflag(casetype, createdby, location, comment, status) VALUES(%s,%s,%s,%s, %s)'
            , (flag.casetype, flag.createdby, flag.location, flag.comment,
            flag.status))

    def get_all(self):
        self.cursor.execute('SELECT * FROM redflag')
        return self.cursor.fetchall()

    def get_one(self, id):
        self.cursor.execute('SELECT * FROM redflag WHERE id = %s', (id,))
        return self.cursor.fetchone()

    def delete_one(self, id):
        self.cursor.execute('DELETE FROM redflag WHERE id = %s', (id,))

    def patch_comment(self, id, comment):
        self.cursor.execute(
            f"UPDATE redflag SET comment = '{comment}' WHERE id = {id}")
        return True

    def patch_location(self, id, location):
        self.cursor.execute(
            f"UPDATE redflag SET location='{location}' WHERE id = {id}")
        return True


class ValidationRedFlags:

    def validate_redflag(self, createdby, casetype, location, status, comment):
        if not createdby and casetype and location and status and comment:
            return jsonify({'message': 'No field should be left empty'})

from app.model.db import DatabaseConnection
from flask import jsonify
import datetime
import json

cursor = DatabaseConnection().cursor

class RedFlag:

    # initialization
    def __init__(self, **kwargs):
        self.id = kwargs.get("id")
        self.casetype = kwargs.get("casetype")
        self.createdby = kwargs.get("createdby")
        self.location = kwargs.get("location")
        self.status = kwargs.get("status")
        self.comment = kwargs.get("comment")
        self.cursor = cursor

    # -------------------------------------------redflag-----------------------------------------------_
    def create_redflag(self, flag):
        self.cursor.execute("INSERT INTO redflag(casetype, createdby, location, comment, status)"
                            " VALUES(%s,%s,%s,%s, %s)", (flag.casetype, flag.createdby, flag.location,
                                                                flag.comment, flag.status
                                                                ))


    # gets all the incidents regardless of the casetype
    def get_all(self):
        self.cursor.execute("SELECT * FROM redflag")
        return self.cursor.fetchall()


    # gets a specific incident by id regardless of the casetype
    def get_one(self, id):
        self.cursor.execute("SELECT * FROM redflag WHERE id = %s", (id,))
        return self.cursor.fetchone()


    # deletes a specific incident regardless of the casetype
    def delete_one(self, id):
        self.cursor.execute("DELETE FROM redflag WHERE id = %s", (id,))


    # edits a comment of the incident regardless of the casetype 
    def patch_comment(self, id, comment):
        self.cursor.execute(f"UPDATE redflag SET comment = '{comment}' WHERE id = {id}")
        return True


    # edits a location of the incident regardless of the casetype
    def patch_location(self, id, location):
        self.cursor.execute(f"UPDATE redflag SET location='{location}' WHERE id = {id}")
        return True
    
# validation for the redflags
class ValidationRedFlags:

    def validate_redflag(self, createdby, casetype, location, status, comment):
        if not createdby and casetype and location and status and comment:
            return jsonify({"message": "No field should be left empty"})

  
       

       