-
-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add hackathon projects * add templates * fix isort * add show/hide project page button * add save/create and logic * upgrade select2 * migrations update * fix query by standard bounty id and validations * add project adition modal to fullfilment success * pagination and missing change * secure img upload backend * review fixes * review comments
- Loading branch information
1 parent
98a1a15
commit d31397a
Showing
18 changed files
with
764 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// document.result.pk | ||
const projectModal = (bountyId, projectId) => { | ||
$('#modalProject').bootstrapModal('hide'); | ||
const modalUrl = projectId ? `/modal/new_project/${bountyId}/${projectId}/` : `/modal/new_project/${bountyId}/`; | ||
|
||
$.ajax({ | ||
url: modalUrl, | ||
type: 'GET', | ||
cache: false | ||
}).done(function(result) { | ||
$('body').append(result); | ||
let data = $('.team-users').data('initial') ? $('.team-users').data('initial').split(', ') : []; | ||
|
||
userSearch('.team-users', false, '', data, true, false); | ||
$('#modalProject').bootstrapModal('show'); | ||
$('[data-toggle="tooltip"]').bootstrapTooltip(); | ||
|
||
$('#projectForm').on('submit', function(e) { | ||
e.preventDefault(); | ||
let logo = $(this)[0]['logo'].files[0]; | ||
let formData = new FormData(); | ||
let data = $(this).serializeArray(); | ||
|
||
formData.append('logo', logo); | ||
|
||
for (let i = 0; i < data.length; i++) { | ||
formData.append(data[i].name, data[i].value); | ||
} | ||
|
||
const sendConfig = { | ||
url: '/modal/save_project/', | ||
method: 'POST', | ||
data: formData, | ||
processData: false, | ||
dataType: 'json', | ||
contentType: false | ||
}; | ||
|
||
$.ajax(sendConfig).done(function(response) { | ||
if (!response.success) { | ||
return _alert(response.msg, 'error'); | ||
} | ||
delete localStorage['pendingProject']; | ||
$('#modalProject').bootstrapModal('hide'); | ||
return _alert({message: response.msg}, 'info'); | ||
|
||
}).fail(function(data) { | ||
_alert(data.responseJSON['error'], 'error'); | ||
}); | ||
|
||
}); | ||
}); | ||
|
||
$(document).on('change', '#project_logo', function() { | ||
previewFile($(this)); | ||
}); | ||
}; | ||
|
||
$(document, '#modalProject').on('hide.bs.modal', function(e) { | ||
$('#modalProject').remove(); | ||
$('#modalProject').bootstrapModal('dispose'); | ||
}); | ||
|
||
const previewFile = function(elem) { | ||
let preview = document.querySelector('#img-preview'); | ||
let file = elem[0].files[0]; | ||
let reader = new FileReader(); | ||
|
||
reader.onloadend = function() { | ||
let imageURL = reader.result; | ||
|
||
getImageSize(imageURL, function(imageWidth, imageHeight) { | ||
if (imageWidth !== imageHeight) { | ||
elem.val(''); | ||
preview.src = elem.data('imgplaceholder'); | ||
return alert('Please use a square image'); | ||
} | ||
preview.src = reader.result; | ||
}); | ||
}; | ||
|
||
if (file) { | ||
reader.readAsDataURL(file); | ||
} | ||
}; | ||
|
||
function getImageSize(imageURL, callback) { | ||
let image = new Image(); | ||
|
||
image.onload = function() { | ||
callback(this.naturalWidth, this.naturalHeight); | ||
}; | ||
image.src = imageURL; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by Django 2.2.4 on 2019-11-05 00:29 | ||
|
||
import app.utils | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import economy.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dashboard', '0060_auto_20191023_1430'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='HackathonProject', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_on', models.DateTimeField(db_index=True, default=economy.models.get_time)), | ||
('modified_on', models.DateTimeField(default=economy.models.get_time)), | ||
('name', models.CharField(max_length=255)), | ||
('logo', models.ImageField(blank=True, help_text='Project Logo', null=True, upload_to=app.utils.get_upload_filename)), | ||
('work_url', models.URLField(help_text='Repo or PR url')), | ||
('summary', models.TextField(blank=True, default='')), | ||
('badge', models.URLField(blank=True, db_index=True, help_text='badge img url', null=True)), | ||
('status', models.CharField(blank=True, choices=[('invalid', 'invalid'), ('pending', 'pending'), ('accepted', 'accepted'), ('completed', 'completed')], max_length=20)), | ||
('bounty', models.ForeignKey(help_text='bounty prize url', on_delete=django.db.models.deletion.CASCADE, related_name='project_bounty', to='dashboard.Bounty')), | ||
('hackathon', models.ForeignKey(help_text='Hackathon event', on_delete=django.db.models.deletion.CASCADE, related_name='project_event', to='dashboard.HackathonEvent')), | ||
('profiles', models.ManyToManyField(related_name='project_profiles', to='dashboard.Profile')), | ||
], | ||
options={ | ||
'ordering': ['-name'], | ||
}, | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
app/dashboard/migrations/0062_hackathonevent_show_results.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.2.4 on 2019-11-05 00:29 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dashboard', '0061_hackathonproject'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='hackathonevent', | ||
name='show_results', | ||
field=models.BooleanField(default=True, help_text='Hide/Show the links to access hackathon results'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.