auto-claude: subtask-1-2 - Add ITAudit SQLAlchemy model to database.py
Add comprehensive ITAudit model with all columns for 9-section IT audit form: - Scores (overall, completeness, security, collaboration) - IT Contact fields - Cloud & Identity (Azure AD, M365, Google Workspace) - Server Infrastructure (virtualization, OS) - Endpoints (employee/computer counts, MDM) - Security (antivirus, EDR, VPN, MFA) - Backup & Disaster Recovery (Proxmox PBS support) - Monitoring (Zabbix integration placeholder) - Business Apps (ticketing, ERP, CRM) - Active Directory configuration - Collaboration flags for cross-company matching Includes helper properties for maturity labels and score categories. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
8edcda52e3
commit
2df1ed324f
155
database.py
155
database.py
@ -14,10 +14,11 @@ Models:
|
||||
- CompanyWebsiteAnalysis: Website analysis and SEO metrics
|
||||
- MaturityAssessment: Historical tracking of maturity scores
|
||||
- GBPAudit: Google Business Profile audit results
|
||||
- ITAudit: IT infrastructure audit results
|
||||
|
||||
Author: Norda Biznes Development Team
|
||||
Created: 2025-11-23
|
||||
Updated: 2026-01-08 (GBP Audit Tool)
|
||||
Updated: 2026-01-09 (IT Audit Tool)
|
||||
"""
|
||||
|
||||
import os
|
||||
@ -1221,6 +1222,158 @@ class GBPAudit(Base):
|
||||
return 'poor'
|
||||
|
||||
|
||||
# ============================================================
|
||||
# IT INFRASTRUCTURE AUDIT
|
||||
# ============================================================
|
||||
|
||||
class ITAudit(Base):
|
||||
"""
|
||||
IT infrastructure audit for companies.
|
||||
Tracks IT infrastructure, security posture, and collaboration readiness.
|
||||
Used for cross-company collaboration matching.
|
||||
"""
|
||||
__tablename__ = 'it_audits'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
company_id = Column(Integer, ForeignKey('companies.id', ondelete='CASCADE'),
|
||||
nullable=False, index=True)
|
||||
|
||||
# Audit timestamp and metadata
|
||||
audit_date = Column(DateTime, default=datetime.now, nullable=False, index=True)
|
||||
audit_source = Column(String(50), default='form') # form, api_sync
|
||||
audited_by = Column(Integer, ForeignKey('users.id'))
|
||||
|
||||
# === SCORES (0-100) ===
|
||||
overall_score = Column(Integer)
|
||||
completeness_score = Column(Integer)
|
||||
security_score = Column(Integer)
|
||||
collaboration_score = Column(Integer)
|
||||
maturity_level = Column(String(20)) # basic, developing, established, advanced
|
||||
|
||||
# === SECTION 1: IT CONTACT ===
|
||||
has_it_manager = Column(Boolean, default=False)
|
||||
it_outsourced = Column(Boolean, default=False)
|
||||
it_provider_name = Column(String(255))
|
||||
it_contact_name = Column(String(255))
|
||||
it_contact_email = Column(String(255))
|
||||
|
||||
# === SECTION 2: CLOUD & IDENTITY ===
|
||||
has_azure_ad = Column(Boolean, default=False)
|
||||
azure_tenant_name = Column(String(255))
|
||||
azure_user_count = Column(String(20)) # Range: 1-10, 11-50, 51-100, 100+
|
||||
has_m365 = Column(Boolean, default=False)
|
||||
m365_plans = Column(ARRAY(String)) # Business Basic, Business Standard, E3, E5, etc.
|
||||
teams_usage = Column(ARRAY(String)) # chat, meetings, files, phone
|
||||
has_google_workspace = Column(Boolean, default=False)
|
||||
|
||||
# === SECTION 3: SERVER INFRASTRUCTURE ===
|
||||
server_count = Column(String(20)) # Range: 0, 1-3, 4-10, 10+
|
||||
server_types = Column(ARRAY(String)) # physical, vm_onprem, cloud_iaas
|
||||
virtualization_platform = Column(String(50)) # none, vmware, hyperv, proxmox, kvm
|
||||
server_os = Column(ARRAY(String)) # windows_server, linux_ubuntu, linux_debian, linux_rhel
|
||||
network_firewall_brand = Column(String(100))
|
||||
|
||||
# === SECTION 4: ENDPOINTS ===
|
||||
employee_count = Column(String(20)) # Range: 1-10, 11-50, 51-100, 100+
|
||||
computer_count = Column(String(20)) # Range: 1-10, 11-50, 51-100, 100+
|
||||
desktop_os = Column(ARRAY(String)) # windows_10, windows_11, macos, linux
|
||||
has_mdm = Column(Boolean, default=False)
|
||||
mdm_solution = Column(String(50)) # intune, jamf, other
|
||||
|
||||
# === SECTION 5: SECURITY ===
|
||||
antivirus_solution = Column(String(50)) # none, windows_defender, eset, kaspersky, other
|
||||
has_edr = Column(Boolean, default=False)
|
||||
edr_solution = Column(String(100)) # microsoft_defender_atp, crowdstrike, sentinelone, other
|
||||
has_vpn = Column(Boolean, default=False)
|
||||
vpn_solution = Column(String(50)) # ipsec, wireguard, openvpn, fortinet, other
|
||||
has_mfa = Column(Boolean, default=False)
|
||||
mfa_scope = Column(ARRAY(String)) # email, vpn, erp, all_apps
|
||||
|
||||
# === SECTION 6: BACKUP & DISASTER RECOVERY ===
|
||||
backup_solution = Column(String(50)) # none, veeam, acronis, pbs, azure_backup, other
|
||||
backup_targets = Column(ARRAY(String)) # local_nas, offsite, cloud, tape
|
||||
backup_frequency = Column(String(20)) # daily, weekly, monthly, continuous
|
||||
has_proxmox_pbs = Column(Boolean, default=False)
|
||||
has_dr_plan = Column(Boolean, default=False)
|
||||
|
||||
# === SECTION 7: MONITORING ===
|
||||
monitoring_solution = Column(String(50)) # none, zabbix, prtg, nagios, datadog, other
|
||||
zabbix_integration = Column(JSONB) # {hostname: '', agent_installed: bool, templates: []}
|
||||
|
||||
# === SECTION 8: BUSINESS APPS ===
|
||||
ticketing_system = Column(String(50)) # none, freshdesk, zendesk, jira_service, other
|
||||
erp_system = Column(String(50)) # none, sap, microsoft_dynamics, enova, optima, other
|
||||
crm_system = Column(String(50)) # none, salesforce, hubspot, pipedrive, other
|
||||
document_management = Column(String(50)) # none, sharepoint, google_drive, dropbox, other
|
||||
|
||||
# === SECTION 9: ACTIVE DIRECTORY ===
|
||||
has_local_ad = Column(Boolean, default=False)
|
||||
ad_domain_name = Column(String(255))
|
||||
has_ad_azure_sync = Column(Boolean, default=False) # Azure AD Connect / Cloud Sync
|
||||
|
||||
# === COLLABORATION FLAGS (for matching algorithm) ===
|
||||
open_to_shared_licensing = Column(Boolean, default=False)
|
||||
open_to_backup_replication = Column(Boolean, default=False)
|
||||
open_to_teams_federation = Column(Boolean, default=False)
|
||||
open_to_shared_monitoring = Column(Boolean, default=False)
|
||||
open_to_collective_purchasing = Column(Boolean, default=False)
|
||||
open_to_knowledge_sharing = Column(Boolean, default=False)
|
||||
|
||||
# === RAW DATA & METADATA ===
|
||||
form_data = Column(JSONB) # Full form submission for reference
|
||||
recommendations = Column(JSONB) # AI-generated recommendations
|
||||
audit_errors = Column(Text) # Any errors during audit processing
|
||||
|
||||
# Timestamps
|
||||
created_at = Column(DateTime, default=datetime.now)
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
|
||||
|
||||
# Relationships
|
||||
company = relationship('Company', backref='it_audits')
|
||||
auditor = relationship('User', foreign_keys=[audited_by])
|
||||
|
||||
def __repr__(self):
|
||||
return f'<ITAudit company_id={self.company_id} score={self.overall_score}>'
|
||||
|
||||
@property
|
||||
def maturity_label(self):
|
||||
"""Return Polish label for maturity level"""
|
||||
labels = {
|
||||
'basic': 'Podstawowy',
|
||||
'developing': 'Rozwijający się',
|
||||
'established': 'Ugruntowany',
|
||||
'advanced': 'Zaawansowany'
|
||||
}
|
||||
return labels.get(self.maturity_level, 'Nieznany')
|
||||
|
||||
@property
|
||||
def score_category(self):
|
||||
"""Return score category: excellent, good, needs_work, poor"""
|
||||
if self.overall_score is None:
|
||||
return 'unknown'
|
||||
if self.overall_score >= 80:
|
||||
return 'excellent'
|
||||
elif self.overall_score >= 60:
|
||||
return 'good'
|
||||
elif self.overall_score >= 40:
|
||||
return 'needs_work'
|
||||
else:
|
||||
return 'poor'
|
||||
|
||||
@property
|
||||
def collaboration_flags_count(self):
|
||||
"""Count how many collaboration flags are enabled"""
|
||||
flags = [
|
||||
self.open_to_shared_licensing,
|
||||
self.open_to_backup_replication,
|
||||
self.open_to_teams_federation,
|
||||
self.open_to_shared_monitoring,
|
||||
self.open_to_collective_purchasing,
|
||||
self.open_to_knowledge_sharing
|
||||
]
|
||||
return sum(1 for f in flags if f)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# MEMBERSHIP FEES
|
||||
# ============================================================
|
||||
|
||||
Loading…
Reference in New Issue
Block a user