BLT icon indicating copy to clipboard operation
BLT copied to clipboard

Added all previous GSOC organizations to organizations

Open tsu-ki opened this issue 11 months ago • 16 comments

Closes: https://github.com/OWASP-BLT/BLT/issues/3264 Work-in progress PR (I haven't added consistent UI yet so the cards aren't displayed properly, please don't mind that)

https://github.com/user-attachments/assets/7bd00617-d8da-44c1-93a9-0130ec4e31e0

Summary by CodeRabbit

  • New Features
    • Introduced a dedicated endpoint and page to display information for unverified domains, making it easier to view domain details for specific organizations.
  • Style
    • Revamped the domain listing interface with updated card layouts, improved pagination, and new visual cues (including default logos and unverified badges) for a clearer and more engaging user experience.

tsu-ki avatar Jan 27 '25 19:01 tsu-ki

@DonnieBLT sir, while adding the organizations, I encountered the following problem: Since, an organization's domains are linked to their BLT profile, and not their slug. I'll have to either create a new slug field in Domains model in models.py file or I'll have to manually register each of the organizations domain and then link their domain, so as to create their BLT profile. Can you please guide me on how should I pursue this further ahead? thank you.

tsu-ki avatar Jan 27 '25 19:01 tsu-ki

Approach to Follow:

  1. Since an organization's domains are linked to their BLT profile, you need to update the model first.

  2. As we haven’t linked domains to BLT profiles yet, we need to be very cautious with the code. Initially, when creating an organization manually, we will not assign any specific user to it.

  3. In the future, if a manager or admin comes to BLT to create an organization account, we will check whether their organization (without a user) already exists in our system. This verification will be done using their email address.

  4. If the organization already exists, we will ask them to confirm ownership. This can be done via OTP verification or by checking whether the user is already verified.

  5. Once verified, the user can then be linked to their organization.

Points to Consider:

  1. First, remove the website/fixtures/merged_organizations.json file, as it is not a robust approach. Instead, write a script to fetch the data and apply conditions to ensure all data is updated yearly. Also, consider the script's complexity and execution time.

  2. Make changes to the domainlist.html file and the organization view file only if absolutely necessary. For now, I believe you should focus only on making changes to the organization creation process and ensuring the necessary condition checks mentioned earlier are implemented.

@DonnieBLT , could you please provide your feedback on this suggestion? Also, let me know if there's anything you'd like to add or remove.

@tsu-ki , if you have any questions, feel free to ask—I'm here !

JisanAR03 avatar Jan 27 '25 20:01 JisanAR03

Sounds good!

DonnieBLT avatar Jan 27 '25 20:01 DonnieBLT

Approach to Follow:

  1. Since an organization's domains are linked to their BLT profile, you need to update the model first.
  2. As we haven’t linked domains to BLT profiles yet, we need to be very cautious with the code. Initially, when creating an organization manually, we will not assign any specific user to it.
  3. In the future, if a manager or admin comes to BLT to create an organization account, we will check whether their organization (without a user) already exists in our system. This verification will be done using their email address.
  4. If the organization already exists, we will ask them to confirm ownership. This can be done via OTP verification or by checking whether the user is already verified.
  5. Once verified, the user can then be linked to their organization.

Points to Consider:

  1. First, remove the website/fixtures/merged_organizations.json file, as it is not a robust approach. Instead, write a script to fetch the data and apply conditions to ensure all data is updated yearly. Also, consider the script's complexity and execution time.
  2. Make changes to the domainlist.html file and the organization view file only if absolutely necessary. For now, I believe you should focus only on making changes to the organization creation process and ensuring the necessary condition checks mentioned earlier are implemented.

@DonnieBLT , could you please provide your feedback on this suggestion? Also, let me know if there's anything you'd like to add or remove.

@tsu-ki , if you have any questions, feel free to ask—I'm here !

@JisanAR03 thank you so much for your extensive explanation, it cleared a lot of things for me. Firstly, I would like to address my approach to solving this. I was considering re-introducing slug field and using conditional statements, where if an org's domain isn't linked to their BLT profile page yet, a slug is created for that org and instead that slug can be linked to their profile page. So, following route would be followed for gsoc orgs present under website/fixtures/merged_organizations.json: org url fetched from json file -> check if their domain is linked or not -> if not, slug is created for this org, and instead slug is linked to their BLT page. Secondly, I created multiple scripts to scrap org information but since gsoc archive doesn't contain information about orgs which participated before 2016, I had to scrap per year information, which didn't include data fields such as logo and correct urls. website/fixtures/merged_organizations.json was formed after combining multiple json files. I tried using Bing API, which is professionally used for web scraping, but it couldn't provide satisfactory results and took too much time to execute. plus, the cost be a factor aswell. I do agree that it's not a robust approach but I haven't been able to find a better approach yet. If you can help me with this, I would be very grateful.

@DonnieBLT sir, please review this and guide me on this, thank you!

tsu-ki avatar Jan 27 '25 20:01 tsu-ki

@tsu-ki , please consider :

  1. verifying an organization before linking it to a user as i mention before, ensuring accurate mapping.

2 . Using slugs as a workaround for missing domain links might lead to inconsistencies in future updates. and keeps the organization-user mapping clean without introducing unnecessary fields.

  1. focus on refining the organization creation process with careful condition checks.

  2. Give me the script you were testing with. Let me check. If I can't do anything with that, then we will go with your approach.

JisanAR03 avatar Jan 27 '25 21:01 JisanAR03

@tsu-ki , please consider :

  1. verifying an organization before linking it to a user as i mention before, ensuring accurate mapping.

2 . Using slugs as a workaround for missing domain links might lead to inconsistencies in future updates. and keeps the organization-user mapping clean without introducing unnecessary fields.

  1. focus on refining the organization creation process with careful condition checks.
  2. Give me the script you were testing with. Let me check. If I can't do anything with that, then we will go with your approach.

I've shared the script with you on slack, please look into it. I'll create a minimal process which checks whether an org exists in the DB or not, if it does then whether it's domain is linked or not. I'll have to find my way around for saving the JSON file organisations and using their domains correctly. thank you for your help!

tsu-ki avatar Jan 28 '25 08:01 tsu-ki

@JisanAR03 @DonnieBLT I've created a seperate class that handles unverified organizations using path("domain/<str:org_name>/unverified", UnverifiedDomainView.as_view(), name="domain_unverified"), route.

  • Both verified(organizations whose domains have been linked with their BLT profiles and unverified(organizations without verification); are displayed on Organizations page, unverified org having an unverified tag attached.
  • An unverified organization is determined as unverified, if it does not exist in DB and has been fetched from another source.
  • When user redirects to an unverified organization's domain, they're taken to a different page, which shows that they're unverified.
  • Incorporating this required changes only in organizations.py, domain_list.html, .urls.py and creating a new template file. Please review this approach and suggest how can I improve, make changes to it. thank you!

https://github.com/user-attachments/assets/d01cfb76-de23-4bef-9246-280260d8023e

tsu-ki avatar Jan 28 '25 13:01 tsu-ki

can you please add a new field in the organisation table for gsoc_years for a comma separated list - and update all the css to tailwind? Also we don't need the unverified domainview anymore as we will have a new organization page soon.

sure, I'll make the required changes and update PR. I'm shifting to a new place, so it might take me a couple of days to complete this. I hope that won't be a problem, thank you for your understanding

tsu-ki avatar Feb 16 '25 07:02 tsu-ki

can you please add a new field in the organisation table for gsoc_years for a comma separated list - and update all the css to tailwind? Also we don't need the unverified domainview anymore as we will have a new organization page soon.

sure, I'll make the required changes and update PR. I'm shifting to a new place, so it might take me a couple of days to complete this. I hope that won't be a problem, thank you for your understanding

Sounds good! Good luck with the move!

DonnieBLT avatar Feb 17 '25 08:02 DonnieBLT

/kudos

DonnieBLT avatar Feb 19 '25 02:02 DonnieBLT

this is a bit outdated now, feel free to revise it and make it work for the new layout this could be one script - see the recent gsoc import

DonnieBLT avatar Mar 03 '25 02:03 DonnieBLT

@coderabbitai please make the changes

DonnieBLT avatar Mar 16 '25 03:03 DonnieBLT

Walkthrough

This pull request introduces new functionality for handling unverified organization domains. A new URL pattern and corresponding view have been added to route requests for unverified domains. The domain management logic has been updated to merge verified domains from the database with unverified ones sourced from a JSON file, modify pagination, and redirect unverified domain detail requests appropriately. Additionally, the domain listing interface has been redesigned with updated HTML templates and styling improvements, and a new template has been added for unverified domains.

Changes

File(s) Change Summary
blt/urls.py
website/views/organization.py
Added new URL route for unverified domains and introduced the UnverifiedDomainView. Updated DomainListView to merge database domains with unverified data from a JSON file, increased pagination from 20 to 30 items, and modified DomainDetailView to redirect unverified domains and adjust issue retrieval.
website/templates/domain_list.html
website/templates/unverified_domain.html
Redesigned domain listing layout by updating grid styling with a fixed column width, new card structure, added styling classes (.unverified-badge, .years, .pagination), revised logo display logic, and introduced a new template (unverified_domain.html) to present details for unverified domains.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant R as URL Router
    participant UD as UnverifiedDomainView
    participant T as Unverified Domain Template

    U->>R: Request /domain/{org_name}/unverified
    R->>UD: Route request to UnverifiedDomainView
    UD->>UD: Load unverified organization data from JSON
    alt Organization found
        UD->>T: Render unverified_domain.html with org details
    else Organization not found
        UD->>U: Return Http404 error
    end
sequenceDiagram
    participant U as User
    participant R as URL Router
    participant DD as DomainDetailView
    participant UD as UnverifiedDomainView
    participant T as Template

    U->>R: Request domain detail
    R->>DD: Process detail request
    DD->>DD: Check domain verification status
    alt Domain is unverified
        DD->>UD: Redirect to UnverifiedDomainView
        UD->>T: Render unverified_domain.html
    else Domain is verified
        DD->>T: Render verified domain details with issues using updated pagination
    end
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Mar 16 '25 03:03 coderabbitai[bot]

[!TIP] For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Let's first understand the PR changes
git show --name-only

# Look for the organization model
fd "models.py" | xargs grep -l "class Organization" || fd "models.py" | xargs grep -l "organization"

# Look for recent GSOC import scripts or related files
fd "gsoc.*import" || fd "import.*gsoc" || fd -e py | xargs grep -l "gsoc" | grep -v test

# Check the current PR branch files
git ls-files | grep -E "organization|gsoc"

Length of output: 65793


🏁 Script executed:

#!/bin/bash
# Find the organization model
cat website/models.py | grep -A 20 "class Organization" || cat website/models.py | grep -A 20 "class Company"

# Look for recent GSOC import scripts
fd -e py | xargs grep -l "gsoc" | head -10

# Look at the merged_organizations.json file mentioned in earlier comments
cat website/fixtures/merged_organizations.json | head -20

# Check if there's a recent commit related to GSOC import
git log --grep="gsoc" -n 5 --oneline

Length of output: 2966


🏁 Script executed:

#!/bin/bash
# Look for more recent GSOC import scripts and files
git log --grep="gsoc import" -n 5 --oneline
git log --grep="organization" -n 5 --oneline

# Search for all files containing 'gsoc' in their content
fd -e py | xargs grep -l "gsoc" | grep -v test

# Let's see if there are any migration files for adding fields to the Organization model
fd "migrations" | grep -l "Organization" | xargs grep -l "add_field"

# Look at any recent commits touching the organization model or fixtures
git log --oneline -n 10 website/models.py
git log --oneline -n 10 website/fixtures/merged_organizations.json

# Check for any recent commits that might be related to the new layout mentioned
git log --oneline -n 20 | grep -i layout

Length of output: 155


🏁 Script executed:

#!/bin/bash
# Check the Organization model definition
cat website/models.py | grep -A 30 "class Organization"

# Check the merged_organizations.json file format
head -30 website/fixtures/merged_organizations.json

# Look for related code
grep -r "gsoc.*import" --include="*.py" .

# Check for recent changes related to organization layout
git log -p -n 1 --grep="organization"

# Let's examine the current PR branch changes
git diff HEAD^ HEAD

Length of output: 4044


🏁 Script executed:

#!/bin/bash
# Let's create a migration file to add the gsoc_years field to the Organization model
echo "
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('website', '0184_merge_0183_merge_20250124_0618_0183_slackbotactivity'),
    ]

    operations = [
        migrations.AddField(
            model_name='organization',
            name='gsoc_years',
            field=models.CharField(blank=True, max_length=255, null=True, help_text='Comma-separated list of years participated in Google Summer of Code'),
        ),
    ]
" > website/migrations/0185_organization_gsoc_years.py

# Let's find files related to the organization view or template
fd -e html | grep -i organization
fd -e py | grep -i organization

# Look for any templates that might need CSS update to Tailwind
fd -e html | grep -i domain

Length of output: 2952


@DonnieBLT I'll implement the requested changes based on our previous discussions. Here's what I'll do:

  1. I've already added a migration file for the new gsoc_years field to the Organization model:
# website/migrations/0185_organization_gsoc_years.py
from django.db import migrations, models

class Migration(migrations.Migration):
    dependencies = [
        ('website', '0184_merge_0183_merge_20250124_0618_0183_slackbotactivity'),
    ]

    operations = [
        migrations.AddField(
            model_name='organization',
            name='gsoc_years',
            field=models.CharField(blank=True, max_length=255, null=True, help_text='Comma-separated list of years participated in Google Summer of Code'),
        ),
    ]
  1. I'll update the CSS in the relevant templates to use Tailwind instead of traditional CSS, particularly focusing on domain_list.html and related organization templates.

  2. I'll remove the unverified domainview as you mentioned a new organization page is coming soon.

  3. I'll modify the import script to utilize the data from the merged_organizations.json file to populate the Organization model with the GSOC organizations and their participation years.

Let me know if there are any specific requirements or considerations for the implementation.

coderabbitai[bot] avatar Mar 16 '25 03:03 coderabbitai[bot]

/giphy nice to have

DonnieBLT avatar Mar 20 '25 22:03 DonnieBLT

Giphy GIF

github-actions[bot] avatar Mar 20 '25 22:03 github-actions[bot]