diff --git a/app/app/utils.py b/app/app/utils.py index 5dade855d73..cce6f3c43b3 100644 --- a/app/app/utils.py +++ b/app/app/utils.py @@ -17,7 +17,6 @@ import requests from avatar.models import SocialAvatar from avatar.utils import get_user_github_avatar_image -from dashboard.models import Profile from geoip2.errors import AddressNotFoundError from git.utils import _AUTH, HEADERS, get_user from ipware.ip import get_real_ip @@ -161,6 +160,7 @@ def setup_lang(request, user): DoesNotExist: The exception is raised if no profile is found for the specified handle. """ + from dashboard.models import Profile profile = None if user.is_authenticated and hasattr(user, 'profile'): profile = user.profile @@ -174,7 +174,14 @@ def setup_lang(request, user): request.session.modified = True +def get_upload_filename(instance, filename): + salt = token_hex(16) + file_path = os.path.basename(filename) + return f"docs/{getattr(instance, '_path', '')}/{salt}/{file_path}" + + def sync_profile(handle, user=None, hide_profile=True): + from dashboard.models import Profile handle = handle.strip().replace('@', '') data = get_user(handle) email = '' diff --git a/app/assets/v2/js/pages/new_bounty.js b/app/assets/v2/js/pages/new_bounty.js index 54a1d0496c3..f18b06e91c7 100644 --- a/app/assets/v2/js/pages/new_bounty.js +++ b/app/assets/v2/js/pages/new_bounty.js @@ -248,6 +248,7 @@ $(document).ready(function() { estimatedHours: data.hours, fundingOrganisation: data.fundingOrganisation, is_featured: data.featuredBounty, + repo_type: data.repo_type, reservedFor: reservedFor ? reservedFor.text : '', tokenName }; @@ -285,7 +286,8 @@ $(document).ready(function() { jobDescription: data.jobDescription }, funding_organisation: metadata.fundingOrganisation, - is_featured: metadata.featuredBounty, + is_featured: metadata.is_featured, + repo_type: metadata.repo_type, featuring_date: metadata.featuredBounty && new Date().getTime() / 1000 || 0, privacy_preferences: privacy_preferences, funders: [], diff --git a/app/dashboard/helpers.py b/app/dashboard/helpers.py index cbad3d79aeb..c2612e0228b 100644 --- a/app/dashboard/helpers.py +++ b/app/dashboard/helpers.py @@ -431,6 +431,7 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id): 'featuring_date': timezone.make_aware( timezone.datetime.fromtimestamp(metadata.get('featuring_date')), timezone=UTC), + 'repo_type': metadata.get('repo_type', None), 'bounty_owner_github_username': bounty_issuer.get('githubUsername', ''), 'bounty_owner_address': bounty_issuer.get('address', ''), 'bounty_owner_email': bounty_issuer.get('email', ''), @@ -446,7 +447,7 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id): 'bounty_owner_github_username', 'bounty_owner_address', 'bounty_owner_email', 'bounty_owner_name', 'github_comments', 'override_status', 'last_comment_date', 'snooze_warnings_for_days', 'admin_override_and_hide', 'admin_override_suspend_auto_approval', 'admin_mark_as_remarket_ready', - 'funding_organisation', 'bounty_reserved_for_user', 'is_featured', 'featuring_date', + 'funding_organisation', 'bounty_reserved_for_user', 'is_featured', 'featuring_date', 'repo_type', ], ) if latest_old_bounty_dict['bounty_reserved_for_user']: diff --git a/app/dashboard/migrations/0014_auto_20190214_0916.py b/app/dashboard/migrations/0014_auto_20190214_0916.py new file mode 100644 index 00000000000..bd1a4f25c37 --- /dev/null +++ b/app/dashboard/migrations/0014_auto_20190214_0916.py @@ -0,0 +1,34 @@ +# Generated by Django 2.1.5 on 2019-02-14 09:16 + +import app.utils +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0013_bounty_featuring_date'), + ] + + operations = [ + migrations.AddField( + model_name='bounty', + name='repo_type', + field=models.CharField(choices=[('public', 'public'), ('private', 'private')], default='public', max_length=50), + ), + migrations.AddField( + model_name='bounty', + name='unsigned_nda', + field=models.FileField(blank=True, help_text='NDA for private repos.', null=True, upload_to=app.utils.get_upload_filename), + ), + migrations.AddField( + model_name='interest', + name='nda_signed', + field=models.FileField(blank=True, help_text='NDA signed by applicant.', null=True, upload_to=app.utils.get_upload_filename), + ), + migrations.AlterField( + model_name='profile', + name='resume', + field=models.FileField(blank=True, help_text='The profile resume.', null=True, upload_to=app.utils.get_upload_filename), + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index e67cef67be7..58ba405c5a4 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -41,7 +41,7 @@ import pytz import requests -from avatar.utils import get_upload_filename +from app.utils import get_upload_filename from dashboard.tokens import addr_to_token from economy.models import ConversionRate, SuperModel from economy.utils import ConversionRateNotFoundError, convert_amount, convert_token_to_usdt @@ -175,6 +175,10 @@ class Bounty(SuperModel): ('permissionless', 'permissionless'), ('approval', 'approval'), ] + REPO_TYPES = [ + ('public', 'public'), + ('private', 'private'), + ] PROJECT_TYPES = [ ('traditional', 'traditional'), ('contest', 'contest'), @@ -268,10 +272,12 @@ class Bounty(SuperModel): canceled_bounty_reason = models.TextField(default='', blank=True, verbose_name=_('Cancelation reason')) project_type = models.CharField(max_length=50, choices=PROJECT_TYPES, default='traditional') permission_type = models.CharField(max_length=50, choices=PERMISSION_TYPES, default='permissionless') + repo_type = models.CharField(max_length=50, choices=REPO_TYPES, default='public') snooze_warnings_for_days = models.IntegerField(default=0) is_featured = models.BooleanField( default=False, help_text=_('Whether this bounty is featured')) featuring_date = models.DateTimeField(blank=True, null=True) + unsigned_nda = models.FileField(upload_to=get_upload_filename, null=True, blank=True, help_text=_('NDA for private repos.')) token_value_time_peg = models.DateTimeField(blank=True, null=True) token_value_in_usdt = models.DecimalField(default=0, decimal_places=2, max_digits=50, blank=True, null=True) @@ -1455,6 +1461,7 @@ class Interest(models.Model): max_length=7, help_text=_('Whether or not the interest requires review'), verbose_name=_('Needs Review')) + nda_signed = models.FileField(upload_to=get_upload_filename, null=True, blank=True, help_text=_('NDA signed by applicant.')) # Interest QuerySet Manager objects = InterestQuerySet.as_manager() @@ -1746,7 +1753,7 @@ class Profile(SuperModel): job_salary = models.DecimalField(default=1, decimal_places=2, max_digits=50) job_location = JSONField(default=dict) linkedin_url = models.CharField(max_length=255, default='', blank=True, null=True) - resume = models.FileField(upload_to=get_upload_filename, null=True, blank=True, help_text=_('The avatar SVG.')) + resume = models.FileField(upload_to=get_upload_filename, null=True, blank=True, help_text=_('The profile resume.')) objects = ProfileQuerySet.as_manager() diff --git a/app/dashboard/router.py b/app/dashboard/router.py index a5dd0a19df0..89258a0151e 100644 --- a/app/dashboard/router.py +++ b/app/dashboard/router.py @@ -99,7 +99,7 @@ class Meta: 'fulfillment_submitted_on', 'fulfillment_started_on', 'canceled_on', 'canceled_bounty_reason', 'action_urls', 'project_type', 'permission_type', 'attached_job_description', 'needs_review', 'github_issue_state', 'is_issue_closed', 'additional_funding_summary', 'funding_organisation', 'paid', - 'admin_override_suspend_auto_approval', 'reserved_for_user_handle', 'is_featured', 'featuring_date', + 'admin_override_suspend_auto_approval', 'reserved_for_user_handle', 'is_featured', 'featuring_date', 'repo_type', ) def create(self, validated_data): @@ -256,6 +256,11 @@ def get_queryset(self): queryset = queryset.filter( is_featured=self.request.query_params.get('is_featured'), ) + + if 'repo_type' in param_keys: + queryset = queryset.filter( + repo_type=self.request.query_params.get('repo_type'), + ) # order order_by = self.request.query_params.get('order_by') diff --git a/app/dashboard/templates/bounty/new.html b/app/dashboard/templates/bounty/new.html index dfe1877f3c0..06beaa2b546 100644 --- a/app/dashboard/templates/bounty/new.html +++ b/app/dashboard/templates/bounty/new.html @@ -55,12 +55,12 @@