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

Create an Company table and a Team table - allow Teams to be setup by anyone and Teams to belong to companies #1126

Closed
fredfalcon opened this issue Mar 9, 2023 · 5 comments
Assignees
Labels
Milestone

Comments

@fredfalcon
Copy link
Contributor

fredfalcon commented Mar 9, 2023

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()
@pranav-iitr
Copy link
Contributor

/assign

@fredfalcon fredfalcon changed the title Create an Entity table Create an Company table and a Team table - allow Teams to be setup by anyone and Teams to belong to companies Mar 17, 2023
@DonnieBLT DonnieBLT changed the title Create an Company table and a Team table - allow Teams to be setup by anyone and Teams to belong to companies Project: BLT Teams Jan 27, 2024
@HanilJain
Copy link
Contributor

/assign

Copy link
Contributor

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.

@thedudeontitan
Copy link
Contributor

/assign

@github-project-automation github-project-automation bot moved this to Backlog in 📌 All Mar 1, 2024
@DonnieBLT DonnieBLT changed the title Project: BLT Teams Create an Company table and a Team table - allow Teams to be setup by anyone and Teams to belong to companies Mar 3, 2024
@DonnieBLT DonnieBLT removed the project label Mar 3, 2024
@DonnieBLT DonnieBLT moved this from Backlog to Ready in 📌 All Mar 3, 2024
@DonnieBLT DonnieBLT added this to the 9️⃣ 🌀 BLT Teams milestone Jul 21, 2024
@DonnieBLT
Copy link
Collaborator

these are now organizations, anyone can setup an Organization and that can be a team

@github-project-automation github-project-automation bot moved this from Ready to Done in 📌 All Aug 3, 2024
@DonnieBLT DonnieBLT added this to the GSOC 2024 milestone Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

6 participants