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

Clean branch of projects v2 #7638

Merged
merged 15 commits into from
Nov 11, 2020
1 change: 1 addition & 0 deletions app/assets/v2/css/lib/plyr.css

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions app/assets/v2/images/projects/winner-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions app/assets/v2/js/hackathon-projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,38 @@ const projectModal = (bountyId, projectId, callback) => {
let data = $('.team-users').data('initial') ? $('.team-users').data('initial').split(', ') : [];

userSearch('.team-users', false, '', data, true, false);
$('.project__tags').select2({
tags: true,
tokenSeparators: [ ',', ' ' ]
});
$('#modalProject').bootstrapModal('show');
$('[data-toggle="tooltip"]').bootstrapTooltip();
$('#looking-members').on('click', function() {
$('.looking-members').toggle();
});
$('#projectForm').on('submit', function(e) {
e.preventDefault();
const url = $('#videodemo-url').val();
const metadata = getVideoMetadata(url);

let logo = $(this)[0]['logo'].files[0];
let data = $(this).serializeArray();

if (metadata) {
data.push({name: 'videodemo-provider', value: metadata.provider});
}

submitProject(logo, data, callback);
});

$('#videodemo-url').keyup(function(event) {
const url = $('#videodemo-url').val();
const metadata = getVideoMetadata(url);

if (metadata) {
$('#videodemo-provider').val(metadata.provider);
}
});
});

$(document).on('change', '#project_logo', function() {
Expand Down
4 changes: 4 additions & 0 deletions app/assets/v2/js/lib/plyr.min.js

Large diffs are not rendered by default.

251 changes: 251 additions & 0 deletions app/assets/v2/js/lib/vue-plyr.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions app/assets/v2/js/pages/fulfill_bounty/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ fulfillBounty = data => {
'bountyPk': data.bountyPk
};

if (data.videoDemoLink) {
const metadata = getVideoMetadata(data.videoDemoLink);

params['videoDemoLink'] = data.videoDemoLink;
params['videoDemoProvider'] = metadata ? metadata['provider'] : null;
}

$.post(url, params, function(response) {
if (200 <= response.status && response.status <= 204) {
// redirect to bounty page
Expand Down
9 changes: 9 additions & 0 deletions app/assets/v2/js/pages/project-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
let newUrl = `/hackathon/${vm.hackathon['slug']}/projects/${vm.project.id}/${vm.project.name}/${newPathName}?${window.location.search}`;

history.pushState({}, `${vm.hackathon['slug']} - ${newPathName}`, newUrl);
},
getVideoId(videoURL) {
const metadata = getVideoMetadata(videoURL);

if (metadata) {
return metadata['id'];
}

return '';
}
},
data: function() {
Expand Down
71 changes: 71 additions & 0 deletions app/assets/v2/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -1341,3 +1341,74 @@ const get_UUID = () => {

return uuid;
};

const isVimeoProvider = (videoURL) => {
let vimeoId = null;

$.ajax({
url: `https://vimeo.com/api/oembed.json?url=${videoURL}`,
async: false,
success: function(response) {
if (response.video_id) {
vimeoId = response.video_id;
}
}
});

return vimeoId;
};

function isValidUrl(string) {
try {
// eslint-disable-next-line no-new
new URL(string);
} catch (_) {
return false;
}

return true;
}

const getVideoMetadata = (videoURL) => {
const youtube_re = /(?:https?:\/\/|\/\/)?(?:www\.|m\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))([\w-]{11})(?![\w-])/;
const loom_re = /(?:https?:\/\/|\/\/)?(?:www\.)?(?:loom\.com\/share\/)([\w]{32})/;

if (!videoURL || !isValidUrl(videoURL)) {
return null;
}

const youtube_match = videoURL.match(youtube_re);
const loom_match = videoURL.match(loom_re);

if (youtube_match !== null && youtube_match[1].length === 11) {
return {
'provider': 'youtube',
'id': youtube_match[1],
'url': videoURL
};
}

if (loom_match !== null) {
return {
'provider': 'loom',
'id': loom_match[1],
'url': videoURL
};
}

const vimeoId = isVimeoProvider(videoURL);

if (vimeoId) {
return {
'provider': 'vimeo',
'id': vimeoId,
'url': videoURL
};
}

return {
'provider': 'generic',
'id': null,
'url': videoURL
};
};
3 changes: 2 additions & 1 deletion app/dashboard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ def issue_details(request):
response['message'] = 'invalid arguments'
return JsonResponse(response)

url_dict = get_url_dict(clean_bounty_url(url))

try:
url_dict = get_url_dict(clean_bounty_url(url))
if url_dict:
response = get_gh_issue_details(token=token, **url_dict)
else:
Expand Down
24 changes: 24 additions & 0 deletions app/dashboard/migrations/0158_auto_20201026_0814.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.2.4 on 2020-10-26 08:14

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0157_auto_20201016_2225'),
]

operations = [
migrations.AddField(
model_name='hackathonproject',
name='categories',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=200), blank=True, default=list, size=None),
),
migrations.AddField(
model_name='hackathonproject',
name='tech_stack',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=200), blank=True, default=list, size=None),
),
]
2 changes: 2 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5136,6 +5136,8 @@ class HackathonProject(SuperModel):
chat_channel_id = models.CharField(max_length=255, blank=True, null=True)
winner = models.BooleanField(default=False, db_index=True)
extra = JSONField(default=dict, blank=True, null=True)
categories = ArrayField(models.CharField(max_length=200), blank=True, default=list)
tech_stack = ArrayField(models.CharField(max_length=200), blank=True, default=list)
grant_obj = models.ForeignKey(
'grants.Grant',
null=True,
Expand Down
5 changes: 4 additions & 1 deletion app/dashboard/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,15 @@ class HackathonProjectSerializer(serializers.ModelSerializer):
bounty = BountySerializer()
profiles = ProfileSerializer(many=True)
hackathon = HackathonEventSerializer()
comments = serializers.SerializerMethodField()

class Meta:
model = HackathonProject
fields = ('pk', 'chat_channel_id', 'status', 'badge', 'bounty', 'name', 'summary', 'work_url', 'profiles', 'hackathon', 'summary', 'logo', 'message', 'looking_members', 'winner', 'grant_obj', 'admin_url')
fields = ('pk', 'chat_channel_id', 'status', 'badge', 'bounty', 'name', 'summary', 'work_url', 'profiles', 'hackathon', 'summary', 'logo', 'message', 'looking_members', 'winner', 'grant_obj', 'admin_url', 'comments',)
depth = 1

def get_comments(self, obj):
return Activity.objects.filter(activity_type='wall_post', project=obj).count()

class HackathonProjectsPagination(PageNumberPagination):
page_size = 10
Expand Down
5 changes: 5 additions & 0 deletions app/dashboard/templates/addinterest.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ <h5 class="text-center font-title">{% trans "Submit a Plan" %}</h5>
<input type="url" class="form-control" name="work_url" id="work_url" placeholder="https://github.com/gitcoinco/web" required>
</div>

<div class="form-group mt-4">
<label class="font-weight-semibold" for="videodemo-url">Link to Video Demo</label>
<input type="url" class="form-control" name="work_url" id="work_url" placeholder="https://github.com/gitcoinco/web" required>
</div>

<div class="from-group mb-3 mt-4">
<label class="font-weight-semibold" for="project_profiles">Team members</label>
<div class="form__select2 g-multiselect">
Expand Down
7 changes: 7 additions & 0 deletions app/dashboard/templates/bounty/fulfill.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ <h4 class="text-center mb-4">{% trans "Submit Work" %}</h4>
{% endfor %}
</select>
</div>
<div class="mt-2">
<label class="form__label" for="videoDemoLink">{% trans "Video demo Link" %}</label>
<input name='videoDemoLink' id='videoDemoLink' class="form__input font-body" type="text"
placeholder="https://youtu.be/DJartWzDn0E" value=""
required
Copy link
Contributor

@octavioamu octavioamu Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be required, not every bounty make sense to have a video

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed @octavioamu, this was required only for hackathon prizes (bounties)

/>
</div>

{% elif bounty.event %}
<div class="mt-2">
Expand Down
28 changes: 28 additions & 0 deletions app/dashboard/templates/dashboard/hackathon/project_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,34 @@ <h2 class="h5 text-center font-weight-bold mb-4">Let's Get Started!</h2>
<label class="font-weight-semibold" for="work_url">Project Github Repository or Link to Pull Request</label>
<input type="url" class="form-control" name="work_url" id="work_url" value="{{project_selected.work_url}}" placeholder="https://github.com/gitcoinco/web" required>
</div>
<div class="form-group mt-4">
<label class="font-weight-semibold" for="videodemo-url">Link to Video Demo</label>
<div class="d-flex">
<input type="url" class="form-control" name="videodemo-url" id="videodemo-url" value="{{project_selected.extra.video_url}}" placeholder="https://www.youtube.com/watch?v=DJartWzDn0E">
</div>
</div>

<div class="from-group mb-3 mt-4">
<label class="font-weight-semibold" for="project_stack">Built With <small>Add Tech Stack</small></label>
<div class="form__select2 g-multiselect">
<select id="project_stack" class="project__tags" name="tech-stack[]" multiple="multiple" aria-describedby="profilesHelp" required>
{% for stack in project_selected.tech_stack %}
<option selected="selected" value="{{ stack }}">{{ stack }}</option>
{% endfor %}
</select>
</div>
</div>

<div class="from-group mb-3 mt-4">
<label class="font-weight-semibold" for="project_categories">Categories <small>Add Categories</small></label>
<div class="form__select2 g-multiselect">
<select id="project_categories" class="project__tags" name="categories[]" multiple="multiple" aria-describedby="profilesHelp" required>
{% for category in project_selected.categories %}
<option selected="selected" value="{{ category }}">{{ category }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="from-group mb-3 mt-4">
<label class="font-weight-semibold" for="project_profiles">Team Members (Optional) <small>Add Gitcoin Usernames</small></label>
<div class="form__select2 g-multiselect">
Expand Down
Loading