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

Add about section #6715

Merged
merged 7 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
re_path(r'^hackathons/?$', dashboard.views.get_hackathons, name='get_hackathons4'),
url(r'^register_hackathon/', dashboard.views.hackathon_registration, name='hackathon_registration'),
path('api/v0.1/hackathon/<str:hackathon>/save/', dashboard.views.save_hackathon, name='save_hackathon'),
path('api/v0.1/hackathon/<str:hackathon>/resource/', dashboard.views.hackathon_resource, name='hackathon_resource'),

# action URLs
url(r'^funder', retail.views.funder_bounties_redirect, name='funder_bounties_redirect'),
Expand Down
3 changes: 3 additions & 0 deletions app/assets/v2/js/pages/dashboard-hackathon.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,9 @@
case 4:
newPathName = 'participants';
break;
case 5:
newPathName = 'about';
break;
}
let newUrl = `/hackathon/${vm.hackathonObj['slug']}/${newPathName}/${window.location.search}`;

Expand Down
100 changes: 100 additions & 0 deletions app/assets/v2/js/vue-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,106 @@ Vue.component('tribes-settings', {
methods: {}
});

Vue.component('about-hackathon', {
delimiters: [ '[[', ']]' ],
props: [],
data: () => ({
is_registered: document.is_registered,
activePanel: document.activePanel,
hackathonObj: document.hackathonObj,
documentation: document.documentation || [],
quests: document.quests || [],
workshops: document.workshops || [],
new_quest_text: '',
new_quest_url: '',
new_work_url: '',
new_work_text: '',
new_doc_url: '',
new_doc_text: ''
}),
mounted() {
this.fetchResources();
},
methods: {
goTo: function(section, event) {
event.preventDefault();
document.getElementById(section).scrollIntoView();
},
fetchResources: function() {
let vm = this;
const resource_url = `/api/v0.1/hackathon/${document.hackathonObj.id}/resource/`;
const retrieveResources = fetchData(resource_url, 'GET', {}, {'X-CSRFToken': vm.csrf});

$.when(retrieveResources).then((response) => {
vm.documentation = response.resources.filter(resource => resource.type === 'documentation');
vm.quests = response.resources.filter(resource => resource.type === 'quest');
vm.workshops = response.resources.filter(resource => resource.type === 'workshop');
}).fail((error) => {
console.log(error);
});
},
remove_resource: function(resource, name, event) {
event.preventDefault();
let vm = this;

const resource_url = `/api/v0.1/hackathon/${document.hackathonObj.id}/resource/`;
const sendJoin = fetchData(resource_url, 'POST', {
resource: resource,
name: name,
action: 'delete'
}, {'X-CSRFToken': vm.csrf});

$.when(sendJoin).then((response) => {
console.log(vm);
vm.fetchResources();
}).fail((error) => {
_alert(`Failed to update ${resource}`);
console.log(error);
});
},
add_resource: function(resource, name, url, event) {
event.preventDefault();
let vm = this;

if (name.length === 0) {
_alert(`The ${resource} name is missing`, 'warning');
return;
}

if (url.length === 0) {
_alert(`The ${resource} url is missing`, 'warning');
return;
}


const resource_url = `/api/v0.1/hackathon/${document.hackathonObj.id}/resource/`;
const sendJoin = fetchData(resource_url, 'POST', {
resource: resource,
name: name,
url: url
}, {'X-CSRFToken': vm.csrf});

$.when(sendJoin).then((response) => {
vm.documentation = response.resources.filter(resource => resource.type === 'documentation');
vm.quests = response.resources.filter(resource => resource.type === 'quest');
vm.workshops = response.resources.filter(resource => resource.type === 'workshop');
if (resource === 'quest') {
vm.new_quest_text = '';
vm.new_quest_url = '';
} else if (resource === 'documentation') {
vm.new_doc_url = '';
vm.new_doc_text = '';
} else if (resource === 'workshop') {
vm.new_work_url = '';
vm.new_work_text = '';
}
}).fail((error) => {
_alert(`Failed to update ${resource}`);
console.log(error);
});
}
}
});

Vue.component('project-directory', {
delimiters: [ '[[', ']]' ],
Expand Down
20 changes: 20 additions & 0 deletions app/dashboard/migrations/0115_hackathonevent_resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 2.2.4 on 2020-05-26 09:27

import django.contrib.postgres.fields
import django.contrib.postgres.fields.jsonb
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0114_auto_20200522_0730'),
]

operations = [
migrations.AddField(
model_name='hackathonevent',
name='resources',
field=django.contrib.postgres.fields.ArrayField(base_field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict, null=True), blank=True, default=list, size=None),
),
]
3 changes: 2 additions & 1 deletion app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3127,7 +3127,7 @@ def get_desc(self, funded_bounties, fulfilled_bounties):

return f"@{self.handle} is a {role} who has participated in {total_funded_participated} " \
f"transaction{plural} on Gitcoin"


@property
def desc(self):
Expand Down Expand Up @@ -4560,6 +4560,7 @@ class HackathonEvent(SuperModel):
chat_channel_id = models.CharField(max_length=255, blank=True, null=True)
visible = models.BooleanField(help_text=_('Can this HackathonEvent be seeing on /hackathons ?'), default=True)
default_channels = ArrayField(models.CharField(max_length=255), blank=True, default=list)
resources = ArrayField(JSONField(default=dict, blank=True, null=True), blank=True, default=list)
objects = HackathonEventQuerySet.as_manager()

def __str__(self):
Expand Down
Loading