Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion uploader/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class FileSerializer(serializers.Serializer):
name = fields.CharField(allow_blank=True)
id = fields.CharField(allow_blank=True)
description = fields.CharField(max_length=200, allow_blank=True, allow_null=True)

categories = fields.CharField(max_length=200, allow_blank=True, allow_null=True)

class GooglePhotosUploadInputSerializer(serializers.Serializer):
fileList = FileSerializer(many=True)
Expand Down
61 changes: 54 additions & 7 deletions uploader/templates/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,15 @@ <h5 class="card-title text-center">
aria-valuemax="100"
>
100%
</div>
</div>
</div>
</h5>
</div>
</h5>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<!-- prettier-ignore -->
{% endblock body %}
<!-- prettier-ignore -->
Expand Down Expand Up @@ -318,6 +319,46 @@ <h5 class="card-title text-center">
},
width: 80
},
{
title: "Categories",
field: "categories",
formatter: function(cell, formatterParams, onRendered) {
return `<select name="wpCategories" id="wpCategories${
cell.getData()["id"]
}" class="custom-select" value="">

<option title="Abstract" value="Abstract">Abstract</option>
<option title="Animals/Wildlife" value="Animals/Wildlife">Animals/Wildlife</option>
<option title="The Arts" value="The Arts">The Arts</option>
<option title="Backgroudns/Textures" value="Backgroudns/Textures">Backgroudns/Textures</option>
<option title="Beauty/Fashion" value="Beauty/Fashion">Beauty/Fashion</option>
<option title="Buildings/Landmarks" value="Buildings/Landmarks">Buildings/Landmarks</option>
<option title="Business/Finance" value="Business/Finance">Business/Finance</option>
<option title="Celebrities" value="Celebrities">Celebrities</option>
<option title="Editorial" value="Editorial">Editorial</option>
<option title="Education" value="Education">Education</option>
<option title="Food and Drink" value="Food and Drink">Food and Drink</option>
<option title="Healthcare/Medical" value="Healthcare/Medical">Healthcare/Medical</option>
<option title="Holidays" value="Holidays">Holidays</option>
<option title="Illustrations/Clip-Art" value="Illustrations/Clip-Art">Illustrations/Clip-Art</option>
<option title="Industrial" value="Industrial">Industrial</option>
<option title="Interiors" value="Interiors">Interiors</option>
<option title="Miscellaneous" value="Miscellaneous">Miscellaneous</option>
<option title="Nature" value="Nature">Nature</option>
<option title="Objects" value="Objects">Objects</option>
<option title="Parks/Outdoor" value="Parks/Outdoor">Parks/Outdoor</option>
<option title="People" value="People">People</option>
<option title="Religion" value="Religion">Religion</option>
<option title="Science" value="Science">Science</option>
<option title="Signs/Symbols" value="Signs/Symbols">Signs/Symbols</option>
<option title="Sports/Recreation" value="Sports/Recreation">Sports/Recreation</option>
<option title="Technology" value="Technology">Technology</option>
<option title="Transportation" value="Transportation">Transportation</option>
<option title="Vectors" value="Vectors">Vectors</option>
<option title="Vintage" value="Vintage">Vintage</option>
</select>`;
}
},
{
title: "Title",
field: "name",
Expand Down Expand Up @@ -352,6 +393,12 @@ <h5 class="card-title text-center">
fileList: fileStagingTable.getData(),
token: oauthToken
};
for (var x = 0; x < fileData["fileList"].length; x++) {
var sel = document.getElementById(
`wpCategories${fileData["fileList"][x]["id"]}`
);
fileData["fileList"][x]["categories"] = sel.value;
}

function getCookie(name) {
var cookieValue = null;
Expand Down
2 changes: 1 addition & 1 deletion uploader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def post(self, request, format=None, *args, **kwargs):
download_status, done = downloader.next_chunk()

uploaded, image_info = wiki_uploader.upload_file(
file_name=file["name"], file_stream=fh, description=file["description"]
file_name=file["name"], file_stream=fh, description=file["description"], categories=file["categories"]
)
if uploaded:
uploaded_results.append(image_info)
Expand Down
10 changes: 8 additions & 2 deletions uploader/wiki_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(
access_secret=access_secret,
)

def upload_file(self, file_name, file_stream, description=""):
def upload_file(self, file_name, file_stream, description="", categories=""):
if not description:
description = file_name

Expand All @@ -32,7 +32,7 @@ def upload_file(self, file_name, file_stream, description=""):
filename=file_name,
description=description,
ignore=True,
comment="Uploaded with Google drive to commons.",
comment=get_initial_page_text(categories, description),
)
debug_information = "Uploaded: {0} to: {1}, more information: {2}".format(
file_name, self.mw_client.host, upload_result
Expand All @@ -43,3 +43,9 @@ def upload_file(self, file_name, file_stream, description=""):
return False, {}
else:
return True, upload_result["imageinfo"]



def get_initial_page_text(categories="", summary=""):

return "== Summary ==\n{0}\n== Categories ==\n{{{{{1}}}}} ".format(summary, categories)