Add a first implementation of GitHub importing.
parent
bd940fdb8b
commit
f9cf671949
|
@ -6,7 +6,7 @@ from builds.models import Version
|
|||
from django.contrib import admin
|
||||
from redirects.models import Redirect
|
||||
from projects.models import (Project, ImportedFile, ProjectRelationship,
|
||||
EmailHook, WebHook)
|
||||
EmailHook, WebHook, GithubProject)
|
||||
from guardian.admin import GuardedModelAdmin
|
||||
|
||||
|
||||
|
@ -40,3 +40,4 @@ admin.site.register(Project, ProjectAdmin)
|
|||
admin.site.register(ImportedFile, ImportedFileAdmin)
|
||||
admin.site.register(EmailHook)
|
||||
admin.site.register(WebHook)
|
||||
admin.site.register(GithubProject)
|
||||
|
|
|
@ -0,0 +1,171 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from south.utils import datetime_utils as datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
# Adding model 'GithubProject'
|
||||
db.create_table(u'projects_githubproject', (
|
||||
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
('pub_date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
|
||||
('modified_date', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
|
||||
('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='github_projects', to=orm['auth.User'])),
|
||||
('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
|
||||
('full_name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255)),
|
||||
('description', self.gf('django.db.models.fields.TextField')(blank=True)),
|
||||
('git_url', self.gf('django.db.models.fields.CharField')(max_length=200, blank=True)),
|
||||
('ssh_url', self.gf('django.db.models.fields.CharField')(max_length=200, blank=True)),
|
||||
('html_url', self.gf('django.db.models.fields.URLField')(max_length=200, null=True, blank=True)),
|
||||
('active', self.gf('django.db.models.fields.BooleanField')(default=False)),
|
||||
('json', self.gf('django.db.models.fields.TextField')()),
|
||||
))
|
||||
db.send_create_signal(u'projects', ['GithubProject'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
# Deleting model 'GithubProject'
|
||||
db.delete_table(u'projects_githubproject')
|
||||
|
||||
|
||||
models = {
|
||||
u'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
u'auth.permission': {
|
||||
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
u'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||
},
|
||||
u'builds.version': {
|
||||
'Meta': {'ordering': "['-verbose_name']", 'unique_together': "[('project', 'slug')]", 'object_name': 'Version'},
|
||||
'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'built': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'identifier': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'privacy_level': ('django.db.models.fields.CharField', [], {'default': "'public'", 'max_length': '20'}),
|
||||
'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'versions'", 'to': u"orm['projects.Project']"}),
|
||||
'slug': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'supported': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'type': ('django.db.models.fields.CharField', [], {'default': "'unknown'", 'max_length': '20'}),
|
||||
'uploaded': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'verbose_name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
|
||||
},
|
||||
u'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
u'projects.emailhook': {
|
||||
'Meta': {'object_name': 'EmailHook'},
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'emailhook_notifications'", 'to': u"orm['projects.Project']"})
|
||||
},
|
||||
u'projects.githubproject': {
|
||||
'Meta': {'object_name': 'GithubProject'},
|
||||
'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'full_name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
|
||||
'git_url': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
|
||||
'html_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'json': ('django.db.models.fields.TextField', [], {}),
|
||||
'modified_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'pub_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'ssh_url': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'github_projects'", 'to': u"orm['auth.User']"})
|
||||
},
|
||||
u'projects.importedfile': {
|
||||
'Meta': {'object_name': 'ImportedFile'},
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'md5': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'path': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'imported_files'", 'to': u"orm['projects.Project']"}),
|
||||
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),
|
||||
'version': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'imported_filed'", 'null': 'True', 'to': u"orm['builds.Version']"})
|
||||
},
|
||||
u'projects.project': {
|
||||
'Meta': {'ordering': "('slug',)", 'object_name': 'Project'},
|
||||
'analytics_code': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
|
||||
'canonical_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
|
||||
'conf_py_file': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
|
||||
'copyright': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
|
||||
'default_branch': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True', 'blank': 'True'}),
|
||||
'default_version': ('django.db.models.fields.CharField', [], {'default': "'latest'", 'max_length': '255'}),
|
||||
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'django_packages_url': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
|
||||
'documentation_type': ('django.db.models.fields.CharField', [], {'default': "'sphinx'", 'max_length': '20'}),
|
||||
'featured': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'language': ('django.db.models.fields.CharField', [], {'default': "'en'", 'max_length': '20'}),
|
||||
'main_language_project': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'translations'", 'null': 'True', 'to': u"orm['projects.Project']"}),
|
||||
'mirror': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'modified_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'num_major': ('django.db.models.fields.IntegerField', [], {'default': '2', 'max_length': '3', 'null': 'True', 'blank': 'True'}),
|
||||
'num_minor': ('django.db.models.fields.IntegerField', [], {'default': '2', 'max_length': '3', 'null': 'True', 'blank': 'True'}),
|
||||
'num_point': ('django.db.models.fields.IntegerField', [], {'default': '2', 'max_length': '3', 'null': 'True', 'blank': 'True'}),
|
||||
'path': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'privacy_level': ('django.db.models.fields.CharField', [], {'default': "'public'", 'max_length': '20'}),
|
||||
'project_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
|
||||
'pub_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'python_interpreter': ('django.db.models.fields.CharField', [], {'default': "'python'", 'max_length': '20'}),
|
||||
'related_projects': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['projects.Project']", 'null': 'True', 'through': u"orm['projects.ProjectRelationship']", 'blank': 'True'}),
|
||||
'repo': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
|
||||
'repo_type': ('django.db.models.fields.CharField', [], {'default': "'git'", 'max_length': '10'}),
|
||||
'requirements_file': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True', 'blank': 'True'}),
|
||||
'single_version': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'skip': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '255'}),
|
||||
'suffix': ('django.db.models.fields.CharField', [], {'default': "'.rst'", 'max_length': '10'}),
|
||||
'theme': ('django.db.models.fields.CharField', [], {'default': "'default'", 'max_length': '20'}),
|
||||
'use_system_packages': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'use_virtualenv': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'users': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'projects'", 'symmetrical': 'False', 'to': u"orm['auth.User']"}),
|
||||
'version': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
|
||||
'version_privacy_level': ('django.db.models.fields.CharField', [], {'default': "'public'", 'max_length': '20'})
|
||||
},
|
||||
u'projects.projectrelationship': {
|
||||
'Meta': {'object_name': 'ProjectRelationship'},
|
||||
'child': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'superprojects'", 'to': u"orm['projects.Project']"}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'subprojects'", 'to': u"orm['projects.Project']"})
|
||||
},
|
||||
u'projects.webhook': {
|
||||
'Meta': {'object_name': 'WebHook'},
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'webhook_notifications'", 'to': u"orm['projects.Project']"}),
|
||||
'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['projects']
|
|
@ -854,3 +854,25 @@ class WebHook(Notification):
|
|||
|
||||
def __unicode__(self):
|
||||
return self.url
|
||||
|
||||
|
||||
class GithubProject(models.Model):
|
||||
#Auto fields
|
||||
pub_date = models.DateTimeField(_('Publication date'), auto_now_add=True)
|
||||
modified_date = models.DateTimeField(_('Modified date'), auto_now=True)
|
||||
|
||||
user = models.ForeignKey(User, verbose_name=_('User'),
|
||||
related_name='github_projects')
|
||||
name = models.CharField(_('Name'), max_length=255)
|
||||
full_name = models.CharField(_('Full Name'), max_length=255, unique=True)
|
||||
description = models.TextField(_('Description'), blank=True,
|
||||
help_text=_('The reStructuredText '
|
||||
'description of the project'))
|
||||
git_url = models.CharField(_('Git URL'), max_length=200, blank=True)
|
||||
ssh_url = models.CharField(_('SSH URL'), max_length=200, blank=True)
|
||||
html_url = models.URLField(_('HTML URL'), max_length=200, null=True, blank=True)
|
||||
active = models.BooleanField(_('Active'), default=False)
|
||||
json = models.TextField('JSON')
|
||||
|
||||
def __unicode__(self):
|
||||
return "%s -> %s" % (self.user, self.html_url)
|
|
@ -13,6 +13,10 @@ urlpatterns = patterns(
|
|||
'projects.views.private.project_import',
|
||||
name='projects_import'),
|
||||
|
||||
url(r'^import/github/$',
|
||||
'projects.views.private.project_import_github',
|
||||
name='projects_import_github'),
|
||||
|
||||
url(r'^(?P<project_slug>[-\w]+)/$',
|
||||
'projects.views.private.project_manage',
|
||||
name='projects_manage'),
|
||||
|
|
|
@ -12,7 +12,9 @@ from django.template import RequestContext
|
|||
from django.views.generic import ListView
|
||||
from django.utils.decorators import method_decorator
|
||||
|
||||
from allauth.socialaccount.models import SocialToken
|
||||
from guardian.shortcuts import assign
|
||||
from requests_oauthlib import OAuth2Session
|
||||
|
||||
from builds.forms import AliasForm, VersionForm
|
||||
from builds.filters import VersionFilter
|
||||
|
@ -21,18 +23,19 @@ from projects.forms import (ImportProjectForm, build_versions_form,
|
|||
build_upload_html_form, SubprojectForm,
|
||||
UserForm, EmailHookForm, TranslationForm,
|
||||
AdvancedProjectForm, RedirectForm, WebHookForm)
|
||||
from projects.models import Project, EmailHook, WebHook
|
||||
from projects.models import Project, EmailHook, GithubProject, WebHook
|
||||
from projects import constants
|
||||
from redirects.models import Redirect
|
||||
|
||||
|
||||
class ProjectDashboard(ListView):
|
||||
|
||||
"""
|
||||
A dashboard! If you aint know what that means you aint need to.
|
||||
Essentially we show you an overview of your content.
|
||||
"""
|
||||
model = Project
|
||||
template_name='projects/project_dashboard.html'
|
||||
template_name = 'projects/project_dashboard.html'
|
||||
|
||||
@method_decorator(login_required)
|
||||
def dispatch(self, *args, **kwargs):
|
||||
|
@ -45,7 +48,8 @@ class ProjectDashboard(ListView):
|
|||
context = super(ProjectDashboard, self).get_context_data(**kwargs)
|
||||
qs = (Version.objects.active(user=self.request.user)
|
||||
.filter(project__users__in=[self.request.user]))
|
||||
filter = VersionFilter(constants.IMPORTANT_VERSION_FILTERS, queryset=self.get_queryset())
|
||||
filter = VersionFilter(
|
||||
constants.IMPORTANT_VERSION_FILTERS, queryset=self.get_queryset())
|
||||
context['filter'] = filter
|
||||
return context
|
||||
|
||||
|
@ -62,6 +66,7 @@ def project_manage(request, project_slug):
|
|||
return HttpResponseRedirect(reverse('projects_detail',
|
||||
args=[project_slug]))
|
||||
|
||||
|
||||
@login_required
|
||||
def project_edit(request, project_slug):
|
||||
"""
|
||||
|
@ -86,6 +91,7 @@ def project_edit(request, project_slug):
|
|||
context_instance=RequestContext(request)
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
def project_advanced(request, project_slug):
|
||||
"""
|
||||
|
@ -95,7 +101,8 @@ def project_advanced(request, project_slug):
|
|||
project = get_object_or_404(request.user.projects.live(),
|
||||
slug=project_slug)
|
||||
form_class = AdvancedProjectForm
|
||||
form = form_class(instance=project, data=request.POST or None, initial={'num_minor': 2, 'num_major': 2, 'num_point': 2})
|
||||
form = form_class(instance=project, data=request.POST or None, initial={
|
||||
'num_minor': 2, 'num_major': 2, 'num_point': 2})
|
||||
|
||||
if request.method == 'POST' and form.is_valid():
|
||||
form.save()
|
||||
|
@ -224,14 +231,15 @@ def edit_alias(request, project_slug, id=None):
|
|||
class AliasList(ListView):
|
||||
model = VersionAlias
|
||||
template_context_name = 'alias'
|
||||
template_name='projects/alias_list.html',
|
||||
template_name = 'projects/alias_list.html',
|
||||
|
||||
@method_decorator(login_required)
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(AliasList, self).dispatch(*args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
self.project = get_object_or_404(Project.objects.all(), slug=self.kwargs.get('project_slug'))
|
||||
self.project = get_object_or_404(
|
||||
Project.objects.all(), slug=self.kwargs.get('project_slug'))
|
||||
return self.project.aliases.all()
|
||||
|
||||
|
||||
|
@ -244,7 +252,8 @@ def project_subprojects(request, project_slug):
|
|||
|
||||
if request.method == 'POST' and form.is_valid():
|
||||
form.save()
|
||||
project_dashboard = reverse('projects_subprojects', args=[project.slug])
|
||||
project_dashboard = reverse(
|
||||
'projects_subprojects', args=[project.slug])
|
||||
return HttpResponseRedirect(project_dashboard)
|
||||
|
||||
subprojects = project.subprojects.all()
|
||||
|
@ -412,10 +421,68 @@ def project_redirects_delete(request, project_slug):
|
|||
project = get_object_or_404(request.user.projects.live(),
|
||||
slug=project_slug)
|
||||
redirect = get_object_or_404(Redirect.objects.all(),
|
||||
pk=request.POST.get('pk'))
|
||||
pk=request.POST.get('pk'))
|
||||
if redirect.project == project:
|
||||
redirect.delete()
|
||||
else:
|
||||
raise Http404
|
||||
project_dashboard = reverse('projects_redirects', args=[project.slug])
|
||||
return HttpResponseRedirect(project_dashboard)
|
||||
|
||||
|
||||
@login_required
|
||||
def project_import_github(request, repo_type='public', sync=True):
|
||||
"""
|
||||
Integrate with GitHub to pull repos from there.
|
||||
|
||||
Params:
|
||||
|
||||
repo_type - The type of accounts to get for a user. ``private`` or ``public``
|
||||
"""
|
||||
tokens = SocialToken.objects.filter(
|
||||
account__user__username=request.user.username, app__provider='github')
|
||||
if tokens.exists():
|
||||
github_connected = True
|
||||
if sync:
|
||||
repos = []
|
||||
token = tokens[0]
|
||||
session = OAuth2Session(
|
||||
client_id=token.app.client_id,
|
||||
token={
|
||||
'access_token': str(token.token),
|
||||
'token_type': 'bearer'
|
||||
}
|
||||
)
|
||||
resp = session.get(
|
||||
'https://api.github.com/user/repos?per_page=100&type=%s' % repo_type)
|
||||
for repo in resp.json():
|
||||
project, created = GithubProject.objects.get_or_create(
|
||||
user=request.user,
|
||||
name=repo['name'],
|
||||
full_name=repo['full_name'],
|
||||
description=repo['description'],
|
||||
git_url=repo['git_url'],
|
||||
ssh_url=repo['ssh_url'],
|
||||
html_url=repo['html_url'],
|
||||
json=repo,
|
||||
)
|
||||
else:
|
||||
github_connected = False
|
||||
|
||||
repos = GithubProject.objects.filter(user=request.user)
|
||||
for repo in repos:
|
||||
ghetto_repo = repo.git_url.replace('git://', '').replace('.git', '')
|
||||
projects = Project.objects.filter(repo__endswith=ghetto_repo) | Project.objects.filter(repo__endswith=ghetto_repo + '.git')
|
||||
if projects:
|
||||
repo.matches = [project.slug for project in projects]
|
||||
else:
|
||||
repo.matches = []
|
||||
|
||||
return render_to_response(
|
||||
'projects/project_import_github.html',
|
||||
{
|
||||
'repos': repos,
|
||||
'github_connected': github_connected,
|
||||
},
|
||||
context_instance=RequestContext(request)
|
||||
)
|
||||
|
|
|
@ -73,7 +73,7 @@ LOCALE_PATHS = [
|
|||
USE_I18N = True
|
||||
USE_L10N = True
|
||||
SITE_ID = 1
|
||||
SECRET_KEY = 'asciidick'
|
||||
SECRET_KEY = 'replace-this-please'
|
||||
|
||||
ACCOUNT_ACTIVATION_DAYS = 7
|
||||
|
||||
|
@ -174,7 +174,7 @@ INSTALLED_APPS = [
|
|||
'allauth',
|
||||
'allauth.account',
|
||||
'allauth.socialaccount',
|
||||
#'allauth.socialaccount.providers.github',
|
||||
'allauth.socialaccount.providers.github',
|
||||
#'allauth.socialaccount.providers.bitbucket',
|
||||
#'allauth.socialaccount.providers.twitter',
|
||||
]
|
||||
|
|
|
@ -10,27 +10,8 @@
|
|||
|
||||
<h1>{% trans "Sign In" %}</h1>
|
||||
|
||||
{% if socialaccount.providers %}
|
||||
<p>{% blocktrans with site.name as site_name %}Please sign in with one
|
||||
of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a>
|
||||
for a {{site_name}} account and sign in below:{% endblocktrans %}</p>
|
||||
|
||||
<div class="socialaccount_ballot">
|
||||
|
||||
<ul class="socialaccount_providers">
|
||||
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
|
||||
</ul>
|
||||
|
||||
<div class="login-or">{% trans 'or' %}</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% include "socialaccount/snippets/login_extra.html" %}
|
||||
|
||||
{% else %}
|
||||
<p>{% blocktrans %}If you have not created an account yet, then please
|
||||
<a href="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>
|
||||
{% endif %}
|
||||
|
||||
<form class="login" method="POST" action="{% url "account_login" %}">
|
||||
{% csrf_token %}
|
|
@ -0,0 +1,22 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load url from future %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block head_title %}{% trans "Change Password" %}{% endblock %}
|
||||
|
||||
{% block dashboard_bar %}
|
||||
{% with change_password_active="active" %}
|
||||
{% include "dashboard/dashboard_bar.html" %}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{% trans "Change Password" %}</h1>
|
||||
|
||||
<form method="POST" action="{% url 'account_change_password' %}" class="password_change">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit" name="action">{% trans "Change Password" %}</button>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
<ul>
|
||||
<li class="first last {{ import_active }}"><a href="{% url "projects_import" %}">{% trans "Import" %}</a></li>
|
||||
<li class="first last {{ import_github_active }}"><a href="{% url "projects_import_github" %}">{% trans "GitHub" %}</a></li>
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
|
@ -25,8 +26,11 @@
|
|||
<a href="{{ profiles_profile_create }}">{% trans "Create Profile" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="{{ connections_active }}">
|
||||
<a href="{% url 'socialaccount_connections' %}">{% trans "Social Accounts" %}</a>
|
||||
</li>
|
||||
<li class="last {{ change_password_active }}">
|
||||
<a href="/accounts/password/change/">{% trans "Change Password" %}</a>
|
||||
<a href="{% url 'account_set_password' %}">{% trans "Change Password" %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{% trans "Import a GitHub project" %}{% endblock %}
|
||||
|
||||
{% block extra_links %}
|
||||
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}lib/markitup/skins/simple/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}lib/markitup/sets/sphinx/editor.css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}javascript/rtd-import.js"></script>
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}lib/markitup/jquery.markitup.pack.js"></script>
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}lib/markitup/sets/sphinx/editor.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#id_description").markItUp(SphinxDocsSettings); // .markItUp(mySettings);
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block dashboard_bar %}
|
||||
{% with import_github_active="active" %}
|
||||
{% include "dashboard/dashboard_bar.html" %}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content-header %}<h1>{% trans "Import a GitHub project" %}</h1>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if github_connected %}
|
||||
<div class="module">
|
||||
<div class="module-wrapper">
|
||||
<div class="module-list">
|
||||
<div class="module-list-wrapper">
|
||||
<ul>
|
||||
{% for repo in repos %}
|
||||
<li class="module-item">
|
||||
|
||||
<a class="module-item-title" href="{{ repo.html_url }}">{{ repo.name }}</a>
|
||||
{# ({{ repo.git_url }}) #}
|
||||
|
||||
<form method="post" action="{% url 'projects_import' %}">
|
||||
{% csrf_token %}
|
||||
<input name="name" type="hidden" value="{{ repo.name }}" />
|
||||
<input name="repo" type="hidden" value="{{ repo.git_url }}" />
|
||||
<input name="repo_type" type="hidden" value="git" />
|
||||
<input name="description" type="hidden" value="{{ repo.description }}" />
|
||||
<input name="language" type="hidden" value="en" />
|
||||
<input name="project_url" type="hidden" value="{{ repo.homepage }}" />
|
||||
<input name="documentation_type" type="hidden" value="sphinx" />
|
||||
|
||||
{% if repo.matches %}
|
||||
<span class="dropdown" style="position:absolute; right:0px; top:0px;">
|
||||
<span>
|
||||
<a href="{% url 'projects_detail' repo.matches.0 %}">{% trans "View Docs" %}</a>
|
||||
<a href="#">▼</a>
|
||||
</span>
|
||||
<ul>
|
||||
{% for match in repo.matches %}
|
||||
<li><a href="{% url 'projects_detail' match %}">{{ match }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</span>
|
||||
|
||||
{% else %}
|
||||
<ul class="module-item-menu">
|
||||
<span>
|
||||
<input type="submit" value="Create" style="margin: 3px;" />
|
||||
</span>
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
</form>
|
||||
</li>
|
||||
{% empty %}
|
||||
You don't have any public GitHub repositories. Please add some and check back.
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
You don't have any GitHub repositories connected.
|
||||
Go to your <a href="{% url 'socialaccount_connections' %}">Social Accounts</a> to set one up.
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -0,0 +1,61 @@
|
|||
{% extends "socialaccount/base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block head_title %}{% trans "Account Connections" %}{% endblock %}
|
||||
|
||||
{% block dashboard_bar %}
|
||||
{% with connections_active="active" %}
|
||||
{% include "dashboard/dashboard_bar.html" %}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{% trans "Account Connections" %}</h1>
|
||||
|
||||
{% if form.accounts %}
|
||||
<p>{% blocktrans %}You can sign in to your account using any of the following third party accounts:{% endblocktrans %}</p>
|
||||
|
||||
|
||||
<form method="post" action="{% url 'socialaccount_connections' %}">
|
||||
{% csrf_token %}
|
||||
|
||||
<fieldset>
|
||||
{% if form.non_field_errors %}
|
||||
<div id="errorMsg">{{form.non_field_errors}}</div>
|
||||
{% endif %}
|
||||
|
||||
{% for base_account in form.accounts %}
|
||||
{% with base_account.get_provider_account as account %}
|
||||
<div>
|
||||
<label for="id_account_{{base_account.id}}">
|
||||
<input id="id_account_{{base_account.id}}" type="radio" name="account" value="{{base_account.id}}"/>
|
||||
<span class="socialaccount_provider {{base_account.provider}} {{account.get_brand.id}}">{{account.get_brand.name}}</span>
|
||||
{{account}}
|
||||
</label>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
|
||||
<div>
|
||||
<button type="submit">{% trans 'Remove' %}</button>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
|
||||
{% else %}
|
||||
<p>{% trans 'You currently have no social network accounts connected to this account.' %}</p>
|
||||
{% endif %}
|
||||
|
||||
<h2>{% trans 'Add a 3rd Party Account' %}</h2>
|
||||
|
||||
<ul class="socialaccount_providers">
|
||||
{% include "socialaccount/snippets/provider_list.html" with process="connect" %}
|
||||
</ul>
|
||||
|
||||
{% include "socialaccount/snippets/login_extra.html" %}
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue