Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ececc65
Added community on project model, deleted group
SimonSarazin Apr 17, 2015
e52b25b
Added a comment and a related name
SimonSarazin Apr 17, 2015
40cfb67
Changed again related name and modified comment
SimonSarazin Apr 17, 2015
e3dd2c4
Community class is not essential for the moment, i deleted it
SimonSarazin Apr 17, 2015
3f75d5d
Updated migration
SimonSarazin Apr 17, 2015
b851bac
fixed template resource dehydrating + remove team from project resource
freddylimpens Apr 9, 2015
b8bcb5d
Update usage.py
SimonSarazin Apr 10, 2015
171f69a
fixed stuff for project and projectsheet listing
freddylimpens Apr 10, 2015
c0cc4da
Revert part of https://github.com/CommonsDev/dataserver/commit/e61313…
Apr 14, 2015
2f145ee
flake8.
Apr 14, 2015
85a9044
flake8 happyness.
Apr 14, 2015
f82618c
Add Project.groups field + migration + missing migration for Project.…
Apr 14, 2015
df2b88c
Update README.md
atiberghien Apr 14, 2015
51a67b1
version bump for 1.3.
Apr 14, 2015
224edd7
Added community on project model, deleted group
SimonSarazin Apr 17, 2015
6f3525f
Added a comment and a related name
SimonSarazin Apr 17, 2015
e36f9bc
Changed again related name and modified comment
SimonSarazin Apr 17, 2015
e91873d
Community class is not essential for the moment, i deleted it
SimonSarazin Apr 17, 2015
1778647
Updated migration
SimonSarazin Apr 17, 2015
0abd445
removed projectteam migrations
SimonSarazin Apr 20, 2015
f6115ee
Deleted groups and projectteam
SimonSarazin Apr 20, 2015
e2bb3ff
Merge branch 'develop' of https://github.com/SimonSarazin/dataserver …
SimonSarazin Apr 20, 2015
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
17 changes: 5 additions & 12 deletions accounts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from tastypie.http import HttpUnauthorized, HttpForbidden
from tastypie.authentication import Authentication, BasicAuthentication, ApiKeyAuthentication
from tastypie.authorization import DjangoAuthorization, Authorization
from tastypie.constants import ALL_WITH_RELATIONS
from tastypie.models import ApiKey, create_api_key
from tastypie.resources import ModelResource
from tastypie.utils import trailing_slash
Expand Down Expand Up @@ -41,6 +40,8 @@ def dehydrate(self, bundle):
except Profile.DoesNotExist:
pass
bundle.data['groups'] = [{"id" : group.id, "name":group.name} for group in bundle.obj.groups.all()]
#bundle.data['first_name'] = bundle.obj.user.first_name
#bundle.data['last_name'] = bundle.obj.user.last_name
return bundle


Expand Down Expand Up @@ -172,20 +173,15 @@ class Meta:
resource_name = 'account/profile'
authentication = Authentication()
authorization = Authorization()
filtering = {
"id" : ['exact',],
"user" : ALL_WITH_RELATIONS,
}

def dehydrate(self, bundle):
bundle.data["username"] = bundle.obj.username
return bundle

class ObjectProfileLinkResource(ModelResource):
"""
Resource for linking profile with objects s.a a Project, a Category, etc.
"""
content_type = fields.CharField(attribute='content_type__model')
profile = fields.OneToOneField(ProfileResource, 'profile', full=True)
level = fields.IntegerField(attribute='level')
detail = fields.CharField(attribute='detail')
Expand All @@ -198,10 +194,7 @@ class Meta:
authorization = DjangoAuthorization()
default_format = "application/json"
filtering = {
"object_id" : ['exact', ],
"content_type" : ['exact', ],
"profile" : ALL_WITH_RELATIONS,

"object_id" : ['exact', ]
}
always_return_data = True

Expand All @@ -221,7 +214,7 @@ def dispatch_list(self, request, **kwargs):
data = json.loads(request.body)
if 'profile_id' in data:
profile = get_object_or_404(Profile, pk=data['profile_id'])
else:
else:
profile=request.user.profile
objectprofilelink_item, created = ObjectProfileLink.objects.get_or_create(profile=profile,
content_type=ContentType.objects.get(model=kwargs['content_type']),
Expand Down
13 changes: 0 additions & 13 deletions graffiti/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,6 @@ class Meta:
authentication = AnonymousApiKeyAuthentication()
authorization = DjangoAuthorization()

def build_filters(self, filters=None):
if filters is None:
filters = {}

orm_filters = super(TagResource, self).build_filters(filters)

if "content_type" in filters:
qs = Tag.objects.filter(taggit_taggeditem_items__content_type__model=filters['content_type'])

orm_filters["pk__in"] = [i.pk for i in qs]

return orm_filters

def dehydrate(self, bundle):
try:
bundle.data["weight"] = bundle.obj.taggit_taggeditem_items__count
Expand Down
14 changes: 7 additions & 7 deletions projects/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from tastypie.resources import ModelResource
from tastypie import fields

from .models import Project, ProjectProgressRange, ProjectProgress
from .models import Project, ProjectProgressRange, ProjectProgress, ProjectTeam

from scout.api import PlaceResource
from dataserver.authentication import AnonymousApiKeyAuthentication
Expand All @@ -13,23 +13,23 @@ class ProjectProgressRangeResource(ModelResource):
class Meta :
queryset = ProjectProgressRange.objects.all()
allowed_methods = ['get']

filtering = {
"slug": ('exact',),
}

class ProjectProgressResource(ModelResource):
range = fields.ToOneField(ProjectProgressRangeResource, "progress_range")

class Meta:
queryset = ProjectProgress.objects.all()
allowed_methods = ['get']
always_return_data = True

filtering = {
"range": ALL_WITH_RELATIONS,
}


class ProjectResource(ModelResource):
location = fields.ToOneField(PlaceResource, 'location', null=True, blank=True, full=True)
Expand All @@ -49,6 +49,7 @@ class Meta:
always_return_data = True
authentication = AnonymousApiKeyAuthentication()
authorization = DjangoAuthorization()

filtering = {
'slug': ('exact',),
'id' : ('exact', ),
Expand All @@ -66,4 +67,3 @@ class Meta:
# filtering = {
# "project": ALL_WITH_RELATIONS,
# }

Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import DataMigration
from south.v2 import SchemaMigration
from django.db import models

from django.contrib.contenttypes.models import ContentType
from projects.models import ProjectTeam
from accounts.models import ObjectProfileLink

class Migration(DataMigration):
class Migration(SchemaMigration):

def forwards(self, orm):
for team in ProjectTeam.objects.all():
for member in team.members.all():
ObjectProfileLink.objects.get_or_create(content_type = ContentType.objects.get_for_model(team.project),
object_id = team.project.id,
profile = member,
level = 0,
isValidated = True)
team.delete()
# Adding model 'Community'
db.create_table(u'projects_community', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('project', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['projects.Project'])),
))
db.send_create_signal(u'projects', ['Community'])

# Removing M2M table for field groups on 'Project'
db.delete_table(db.shorten_name(u'projects_project_groups'))


def backwards(self, orm):
"Write your backwards methods here."
# Deleting model 'Community'
db.delete_table(u'projects_community')

# Adding M2M table for field groups on 'Project'
m2m_table_name = db.shorten_name(u'projects_project_groups')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('project', models.ForeignKey(orm[u'projects.project'], null=False)),
('group', models.ForeignKey(orm[u'auth.group'], null=False))
))
db.create_unique(m2m_table_name, ['project_id', 'group_id'])


models = {
u'accounts.profile': {
Expand Down Expand Up @@ -67,14 +77,20 @@ def backwards(self, orm):
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'projects.community': {
'Meta': {'object_name': 'Community'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['projects.Project']"})
},
u'projects.project': {
'Meta': {'object_name': 'Project'},
'baseline': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
'begin_date': ('django.db.models.fields.DateField', [], {}),
'begin_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
'created_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'location': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['scout.PostalAddress']", 'null': 'True', 'blank': 'True'}),
'location': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['scout.Place']", 'null': 'True', 'blank': 'True'}),
'progress': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['projects.ProjectProgress']", 'null': 'True', 'blank': 'True'}),
'slug': ('autoslug.fields.AutoSlugField', [], {'unique': 'True', 'max_length': '50', 'populate_from': 'None', 'unique_with': '()'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
Expand All @@ -101,17 +117,22 @@ def backwards(self, orm):
'members': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['accounts.Profile']", 'symmetrical': 'False'}),
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['projects.Project']"})
},
u'scout.place': {
'Meta': {'object_name': 'Place'},
'address': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'place'", 'to': u"orm['scout.PostalAddress']"}),
'geo': ('django.contrib.gis.db.models.fields.PointField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
u'scout.postaladdress': {
'Meta': {'object_name': 'PostalAddress'},
'address_locality': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
'address_region': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
'address_locality': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
'address_region': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
'country': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'post_office_box_number': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True'}),
'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True'}),
'street_address': ('django.db.models.fields.TextField', [], {'null': 'True'})
'post_office_box_number': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'street_address': ('django.db.models.fields.TextField', [], {'blank': 'True'})
}
}

complete_apps = ['projects']
symmetrical = True
complete_apps = ['projects']
96 changes: 96 additions & 0 deletions projects/migrations/0013_auto__del_projectteam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# -*- 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):
# Deleting model 'ProjectTeam'
db.delete_table(u'projects_projectteam')

# Removing M2M table for field members on 'ProjectTeam'
db.delete_table(db.shorten_name(u'projects_projectteam_members'))

# Removing M2M table for field groups on 'Project'
db.delete_table(db.shorten_name(u'projects_project_groups'))


def backwards(self, orm):
# Adding model 'ProjectTeam'
db.create_table(u'projects_projectteam', (
('project', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['projects.Project'])),
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
))
db.send_create_signal(u'projects', ['ProjectTeam'])

# Adding M2M table for field members on 'ProjectTeam'
m2m_table_name = db.shorten_name(u'projects_projectteam_members')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('projectteam', models.ForeignKey(orm[u'projects.projectteam'], null=False)),
('profile', models.ForeignKey(orm[u'accounts.profile'], null=False))
))
db.create_unique(m2m_table_name, ['projectteam_id', 'profile_id'])

# Adding M2M table for field groups on 'Project'
m2m_table_name = db.shorten_name(u'projects_project_groups')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('project', models.ForeignKey(orm[u'projects.project'], null=False)),
('group', models.ForeignKey(orm[u'auth.group'], null=False))
))
db.create_unique(m2m_table_name, ['project_id', 'group_id'])


models = {
u'projects.project': {
'Meta': {'object_name': 'Project'},
'baseline': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
'begin_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
'created_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'location': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['scout.Place']", 'null': 'True', 'blank': 'True'}),
'progress': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['projects.ProjectProgress']", 'null': 'True', 'blank': 'True'}),
'slug': ('autoslug.fields.AutoSlugField', [], {'unique': 'True', 'max_length': '50', 'populate_from': 'None', 'unique_with': '()'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
},
u'projects.projectprogress': {
'Meta': {'ordering': "['order']", 'object_name': 'ProjectProgress'},
'description': ('django.db.models.fields.CharField', [], {'max_length': '500'}),
'icon': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'label': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
'progress_range': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['projects.ProjectProgressRange']"})
},
u'projects.projectprogressrange': {
'Meta': {'object_name': 'ProjectProgressRange'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'slug': ('autoslug.fields.AutoSlugField', [], {'unique': 'True', 'max_length': '50', 'populate_from': "'name'", 'unique_with': '()'})
},
u'scout.place': {
'Meta': {'object_name': 'Place'},
'address': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'place'", 'to': u"orm['scout.PostalAddress']"}),
'geo': ('django.contrib.gis.db.models.fields.PointField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
u'scout.postaladdress': {
'Meta': {'object_name': 'PostalAddress'},
'address_locality': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
'address_region': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
'country': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'post_office_box_number': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'street_address': ('django.db.models.fields.TextField', [], {'blank': 'True'})
}
}

complete_apps = ['projects']
Loading