fritzing / fritzing-parts

Electronic components for use in the Fritzing app (aka the parts library)
http://fritzing.org/parts
Other
506 stars 359 forks source link

Community Contributed Parts #1

Closed dreamalligator closed 10 years ago

dreamalligator commented 10 years ago

Hi! About community contributed parts now that you are on Github; would you like issues here, forks of the parts library, something else, or still contributing parts to the Google issue on parts (link1 / link2)? I still assume the latter-most because of the parts page mentions Until we have a proper parts sharing website, please use our issue tracker to share your part with other Fritzing users. For said parts website, it would be a breeze to use the Github API to make issues and host all contributions here. I volunteer to help :smile:.

Love Fritzing, thanks.

aknoerig commented 10 years ago

Hi! Yes, you can either use the good old Google issue 2753 or make a pull-request to this github repository. Help on the website would be very much appreciated! We are currently building a new website in django, and would like to include a parts gallery similar to the projects one. If you know some Python, it's fairly easy to get started.

dreamalligator commented 10 years ago

Fantastic. I do know some Python!

My idea is for users to add Github authorization to this imaginary parts app.

Submit simple form of:

Then when they submit the form it creates an issued titled with the same title, puts the description in there and attaches the image with file, or if cant attach file, then add file to database and append a link in description.

A really quick example that creates a parts label when one doesnt exist and adds it to the issue that gets its title from the form.

from github import Github
#--------
#auth method just for quick test
owner = 'fritzing'
password = '<my pass>'
project = 'fritzing-parts'
#--------
import requests
params = {
    'client_id': 'af07...637b8',
    'client_secret': 'eb43...c4b',
}
headers = {'accept': 'application/json'}
url = 'https://github.com/login/oauth/access_token'
r = requests.post(url,params=params,headers=headers)
if not r.ok:
    raise Http404
#--------
data = r.json()
g = Github(base_url=base_url,client_id=client_id,client_secret=client_secret)
repo = g.get_user(owner).get_repo(project)
#--------
# get this info from parts submission form
title = 'Banana Led board, 10-pin variety'
author = 'digitalvapor' #not necessarily owner if user didn't authorize with Github
assignee = author #for example
comment = 'The new Adafruit 10-pin banana LED board. Tested for accuracy.'
#--------
# if want to make a milestone
#try:
#    milestone = repo.create_milestone('new parts milestone')
#except:
#    milestone = repo.get_milestone(1)
#--------
try:
    # need a label, before you can use it
    repo.create_label('parts','fbca04')
    #print('debug: created parts label for first time')
except:
    pass
    #print('debug: parts label already made')
finally:
    label = repo.get_label('parts')
#--------
#can put assignee, milestone, label, etc here
issue = repo.create_issue(title,comment,labels=[label])
dreamalligator commented 10 years ago

Also, http://fritzing.org/projects/by-tag/guitar does not return guitar tags, but http://fritzing.org/projects/by-tag/guitar/ does. I believe you can set the settings.py's APPEND_SLASH to True so that the request redirects for people like me who sometimes copy-paste without slashes.

https://docs.djangoproject.com/en/dev/ref/settings/#append-slash

I am marking this as closed, because you addressed my original comment, thanks!