django_coreprotect/models.py

331 lines
9.3 KiB
Python

from django.db import models
from django.contrib.auth.models import User
from datetime import datetime
class CoreProtectUser(User):
class Meta:
proxy = True
permissions = (
('coreprotect_base', 'Can use CoreProtect GUI'),
('coreprotect_extra', 'Can search Chat/Commands'),
('coreprotect_activity', 'Can use CoreProtect Activity Monitor'),
)
class CoArtMap(models.Model):
id = models.IntegerField(primary_key=True)
art = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_art_map'
verbose_name = 'Art Map'
verbose_name_plural = 'Art Maps'
def __str__(self):
return self.art
class CoBlock(models.Model):
time = models.IntegerField(blank=True, null=True)
user = models.IntegerField(blank=True, null=True)
wid = models.IntegerField(blank=True, null=True)
x = models.IntegerField(blank=True, null=True)
y = models.IntegerField(blank=True, null=True)
z = models.IntegerField(blank=True, null=True)
type = models.IntegerField(blank=True, null=True)
data = models.IntegerField(blank=True, null=True)
meta = models.BinaryField(blank=True, null=True)
blockdata = models.BinaryField(blank=True, null=True)
action = models.IntegerField(blank=True, null=True)
rolled_back = models.IntegerField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_block'
verbose_name = 'Block'
verbose_name_plural = 'Blocks'
def __str__(self):
return self.type
class CoBlockdataMap(models.Model):
id = models.IntegerField(primary_key=True)
data = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_blockdata_map'
verbose_name = 'BlockData Map'
verbose_name_plural = 'BlockData Maps'
def __str__(self):
return self.data
class CoChat(models.Model):
time = models.IntegerField(blank=True, null=True)
user = models.IntegerField(blank=True, null=True)
message = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_chat'
verbose_name = 'Chat Message'
verbose_name_plural = 'Chat Messages'
def __str__(self):
return self.message
class CoCommand(models.Model):
time = models.IntegerField(blank=True, null=True)
user = models.IntegerField(blank=True, null=True)
message = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_command'
verbose_name = 'Command'
verbose_name_plural = 'Commands'
def __str__(self):
return self.message
class CoContainer(models.Model):
time = models.IntegerField(blank=True, null=True)
user = models.IntegerField(blank=True, null=True)
wid = models.IntegerField(blank=True, null=True)
x = models.IntegerField(blank=True, null=True)
y = models.IntegerField(blank=True, null=True)
z = models.IntegerField(blank=True, null=True)
type = models.IntegerField(blank=True, null=True)
data = models.IntegerField(blank=True, null=True)
amount = models.IntegerField(blank=True, null=True)
metadata = models.BinaryField(blank=True, null=True)
action = models.IntegerField(blank=True, null=True)
rolled_back = models.IntegerField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_container'
verbose_name = 'Container Transaction'
verbose_name_plural = 'Container Transactions'
def __str__(self):
return self.user
class CoDatabaseLock(models.Model):
status = models.IntegerField(blank=True, null=True)
time = models.IntegerField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_database_lock'
verbose_name = 'Database Lock'
verbose_name_plural = 'Database Locks'
def __str__(self):
return self.status
class CoEntity(models.Model):
time = models.IntegerField(blank=True, null=True)
data = models.BinaryField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_entity'
verbose_name = 'Entity'
verbose_name_plural = 'Entities'
def __str__(self):
return self.time
class CoEntityMap(models.Model):
id = models.IntegerField(primary_key=True)
entity = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_entity_map'
verbose_name = 'Entity Mapping'
verbose_name_plural = 'Entity Mappings'
def __str__(self):
return self.entity
class CoMaterialMap(models.Model):
id = models.IntegerField(primary_key=True)
material = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_material_map'
verbose_name = 'Material Mapping'
verbose_name_plural = 'Material Mappings'
def __str__(self):
return self.material
class CoSession(models.Model):
time = models.IntegerField(blank=True, null=True)
user = models.IntegerField(blank=True, null=True)
wid = models.IntegerField(blank=True, null=True)
x = models.IntegerField(blank=True, null=True)
y = models.IntegerField(blank=True, null=True)
z = models.IntegerField(blank=True, null=True)
action = models.IntegerField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_session'
verbose_name = 'Session'
verbose_name_plural = 'Sessions'
def __str__(self):
return self.user
class CoSign(models.Model):
time = models.IntegerField(blank=True, null=True)
user = models.IntegerField(blank=True, null=True)
wid = models.IntegerField(blank=True, null=True)
x = models.IntegerField(blank=True, null=True)
y = models.IntegerField(blank=True, null=True)
z = models.IntegerField(blank=True, null=True)
color = models.IntegerField(blank=True, null=True)
line_1 = models.TextField(blank=True, null=True)
line_2 = models.TextField(blank=True, null=True)
line_3 = models.TextField(blank=True, null=True)
line_4 = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_sign'
verbose_name = 'Sign'
verbose_name_plural = 'Signs'
def __str__(self):
return "{} | {} | {} | {}".format(self.line_1, self.line_2, self.line_3, self.line_4)
class CoSkull(models.Model):
time = models.IntegerField(blank=True, null=True)
owner = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_skull'
verbose_name = 'Skull'
verbose_name_plural = 'Skulls'
def __str__(self):
return self.owner
class CoUser(models.Model):
time = models.IntegerField(blank=True, null=True)
user = models.TextField(blank=True, null=True)
uuid = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_user'
verbose_name = 'User'
verbose_name_plural = 'Users'
def __str__(self):
return self.user
class CoUsernameLog(models.Model):
time = models.IntegerField(blank=True, null=True)
uuid = models.TextField(blank=True, null=True)
user = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_username_log'
verbose_name = 'Username'
verbose_name_plural = 'Usernames'
def __str__(self):
return self.user
class CoVersion(models.Model):
time = models.IntegerField(blank=True, null=True)
version = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_version'
verbose_name = 'Version'
verbose_name_plural = 'Versions'
def __str__(self):
return self.version
class CoWorld(models.Model):
id = models.IntegerField(primary_key=True)
world = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'co_world'
verbose_name = 'World'
verbose_name_plural = 'Worlds'
def __str__(self):
return self.world
class CoResult(models.Model):
type = models.TextField()
unix = models.TextField()
player = models.TextField()
action = models.TextField()
data = models.TextField()
x = models.TextField()
y = models.TextField()
z = models.TextField()
world = models.TextField()
@property
def display_time(self):
dt = datetime.fromtimestamp(float(self.unix))
return dt.strftime("%b %d, %Y at %I:%M:%S %p")
@property
def display_action(self):
if self.type == "block":
return "Block Break" if self.action == 0 else "Block Place" if self.action == 1 else "Interact/Used"
if self.type == "chat":
return "Chat"
if self.type == "command":
return "Command"
if self.type == "container":
return "Took from Container" if self.action == 0 else "Placed in Container"
return self.action
@property
def display_data(self):
if self.type == "block":
material = self.data.replace("minecraft:", "")
parts = material.split("_")
return " ".join([part.capitalize() for part in parts])
return self.data
class Meta:
managed = False