BLT
BLT copied to clipboard
Create an Company table and a Team table - allow Teams to be setup by anyone and Teams to belong to companies
Create an Company table and a Team table - allow Teams to be setup by anyone and Teams to belong to companies
an Entity table is fine too for things that don't have a company or team - like an OWASP project
class Company(models.Model):
name = models.CharField(max_length=255)
corporate_name = models.CharField(max_length=255)
main_website = one to one with domains
image = models.ImageField(upload_to='entity_images')
description = models.TextField()
# allow any user connected to the company to modify it's settings - users must be verified with a company email address
users = models.ManyToManyField('auth.User', related_name='entities', blank=True)
domains = models.ManyToManyField('Domain', related_name='entities', blank=True)
hunts = models.ManyToManyField('Hunt', related_name='entities', blank=True)
teams = models.ManyToManyField('Team', related_name='entities', blank=True)
def __str__(self):
return self.name
Then run this script;
from django.contrib.auth.models import User
from myapp.models import Entity, Domain, Hunt
# Get all Domain objects
domains = Domain.objects.all()
# Iterate over each Domain object
for domain in domains:
# update this
entity = Company()
entity.name = domain.url.replace('www.', '').replace('.com', '') # Set the entity name based on the domain url
entity.image = 'default_image.jpg' # Set a default image
entity.description = f'This is the entity for {domain.url}' # Set a default description
entity.save() # Save the new entity object
# Get all Users with an email containing the domain name
users = User.objects.filter(email__icontains=domain.url.replace('www.', ''))
entity.users.set(users) # Add the users to the entity using the many-to-many relationship
# Get all Hunt objects that match the domain
hunts = Hunt.objects.filter(domain=domain)
for hunt in hunts:
hunt.entities.add(entity) # Add the entity to the hunt using the many-to-many relationship
hunt.save()
/assign
/assign
You cannot be assigned to this issue because you are already assigned to the following issues without an open pull request: #1239. Please submit a pull request for these issues before getting assigned to a new one.
/assign
these are now organizations, anyone can setup an Organization and that can be a team