|
1 | 1 | """Project forms."""
|
2 | 2 |
|
| 3 | +import datetime |
3 | 4 | import json
|
4 | 5 | from random import choice
|
5 | 6 | from re import fullmatch
|
6 | 7 | from urllib.parse import urlparse
|
7 | 8 |
|
| 9 | +import pytz |
8 | 10 | from allauth.socialaccount.models import SocialAccount
|
9 | 11 | from django import forms
|
10 | 12 | from django.conf import settings
|
11 | 13 | from django.contrib.auth.models import User
|
12 | 14 | from django.db.models import Q
|
13 | 15 | from django.urls import reverse
|
| 16 | +from django.utils import timezone |
14 | 17 | from django.utils.translation import gettext_lazy as _
|
15 | 18 |
|
16 | 19 | from readthedocs.builds.constants import INTERNAL
|
@@ -662,14 +665,23 @@ class Meta:
|
662 | 665 |
|
663 | 666 | def __init__(self, *args, **kwargs):
|
664 | 667 | self.project = kwargs.pop("project", None)
|
| 668 | + |
| 669 | + tzinfo = pytz.timezone("America/Los_Angeles") |
| 670 | + addons_enabled_by_default = timezone.now() > datetime.datetime( |
| 671 | + 2024, 10, 7, 0, 0, 0, tzinfo=tzinfo |
| 672 | + ) |
| 673 | + |
665 | 674 | addons, created = AddonsConfig.objects.get_or_create(project=self.project)
|
666 | 675 | if created:
|
667 |
| - addons.enabled = False |
| 676 | + addons.enabled = addons_enabled_by_default |
668 | 677 | addons.save()
|
669 | 678 |
|
670 | 679 | kwargs["instance"] = addons
|
671 | 680 | super().__init__(*args, **kwargs)
|
672 | 681 |
|
| 682 | + if addons_enabled_by_default: |
| 683 | + self.fields.pop("enabled") |
| 684 | + |
673 | 685 | def clean(self):
|
674 | 686 | if (
|
675 | 687 | self.cleaned_data["flyout_sorting"] == ADDONS_FLYOUT_SORTING_CUSTOM_PATTERN
|
|
0 commit comments