Skip to content

Commit

Permalink
[#584] Merge branch 'feature/django-upgrade' into feature/du584_repla…
Browse files Browse the repository at this point in the history
…ce_perms_codenames_resolver

Conflicts:
	akvo/rsr/admin.py
  • Loading branch information
zzgvh committed Jun 4, 2014
2 parents 8cf80e3 + c20a870 commit 26350f3
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 326 deletions.
3 changes: 2 additions & 1 deletion akvo/api/resources/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
class IATIProjectModelForm(ModelForm):
class Meta:
model = Project
fields = "__all__"


class IATIProjectResource(ModelResource):
Expand Down Expand Up @@ -291,7 +292,7 @@ def get_object_list(self, request):
return object_list
elif request.user.has_perm(opts.app_label + '.' + get_permission_codename(RSR_LIMITED_CHANGE, opts)):
object_list = object_list.published() | object_list.of_partner(
request.user.get_profile().organisation
request.user.userprofile.organisation
)
return object_list.distinct()
return object_list.published()
Expand Down
3 changes: 2 additions & 1 deletion akvo/api/resources/project_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
class ProjectUpdateModelForm(ModelForm):
class Meta:
model = ProjectUpdate
fields = "__all__"


class ProjectUpdateResource(ConditionalFullResource):
Expand Down Expand Up @@ -73,7 +74,7 @@ def dehydrate(self, bundle):
def org_data_for_update(update):
""" return relevant data for the organisation that is linked to an update through the user that created the update
"""
update_org = update.user.get_profile().organisation
update_org = update.user.userprofile.organisation
return dict(
absolute_url=update_org.get_absolute_url(),
long_name=update_org.long_name,
Expand Down
2 changes: 1 addition & 1 deletion akvo/api/resources/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def dehydrate(self, bundle):
if self._meta.authentication.is_authenticated(bundle.request):
if getattr(bundle.request.user, 'get_profile', False):
# get the org of the API key owner
organisation = bundle.request.user.get_profile().organisation
organisation = bundle.request.user.userprofile.organisation
else:
organisation = None
# find out if the user has a profile that's associated with the API key owner org
Expand Down
2 changes: 1 addition & 1 deletion akvo/api/resources/user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Meta:
def get_object_list(self, request):
""" Limit access to the users in your own organisation
"""
organisation = request.user.get_profile().organisation
organisation = request.user.userprofile.organisation
return UserProfile.objects.filter(organisation=organisation)

def dehydrate(self, bundle):
Expand Down
309 changes: 15 additions & 294 deletions akvo/rsr/admin.py

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions akvo/rsr/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ class ProjectUpdateForm(forms.ModelForm):

class Meta:
model = get_model('rsr', 'projectupdate')
exclude = ('created_at', 'project', 'user', 'last_modified_at')
fields = ('title', 'text', 'language', 'photo', 'photo_caption', 'photo_credit', 'video', 'video_caption',
'video_credit')

def clean_video(self):
data = self.cleaned_data['video']
Expand All @@ -393,9 +394,6 @@ def clean_video(self):


class PartnerSiteAdminForm(forms.ModelForm):
class Meta:
model = get_model('rsr', 'partnersite')

def clean_hostname(self):
hostname = slugify(self.cleaned_data['hostname'])
if hostname == 'www': # TODO: test for other reserved hostnames
Expand Down
2 changes: 1 addition & 1 deletion akvo/rsr/iso3166.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
ISO 3166 country names and their corresponding 3166-1-alpha-2 codes
"""
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

ISO_3166_COUNTRIES = (
(u"af", _(u"Afghanistan")),
Expand Down
11 changes: 7 additions & 4 deletions akvo/rsr/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ class Goal(models.Model):


class Benchmark(models.Model):
project = models.ForeignKey(Project, verbose_name=_(u'project'), related_name=_(u'benchmarks'), )
project = models.ForeignKey(Project, verbose_name=_(u'project'), related_name='benchmarks', )
category = models.ForeignKey(Category, verbose_name=_(u'category'), )
name = models.ForeignKey(Benchmarkname, verbose_name=_(u'benchmark name'), )
value = models.IntegerField(_(u'benchmark value'), )
Expand Down Expand Up @@ -1304,7 +1304,7 @@ class UserProfile(models.Model, PermissionBase, WorkflowBase):
'''
Extra info about a user.
'''
user = models.OneToOneField(User)
user = models.OneToOneField(User, related_name='userprofile')
organisation = models.ForeignKey(Organisation)

notes = ValidXMLTextField(verbose_name=_("Notes and comments"), blank=True, default='')
Expand Down Expand Up @@ -1643,7 +1643,10 @@ class Invoice(models.Model):
('ideal', u'iDEAL'),
)
# Setup
test = models.BooleanField(u'test donation', help_text=u'This flag is set if the donation was made in test mode.')
test = models.BooleanField(
u'test donation',
help_text=u'This flag is set if the donation was made in test mode.',
default=False)
engine = ValidXMLCharField(u'payment engine', choices=PAYMENT_ENGINES, max_length=10, default='paypal')
user = models.ForeignKey(User, blank=True, null=True)
project = models.ForeignKey(Project, related_name='invoices')
Expand All @@ -1659,7 +1662,7 @@ class Invoice(models.Model):
status = models.PositiveSmallIntegerField('status', choices=STATUS_CHOICES, default=1)
http_referer = ValidXMLCharField(u'HTTP referer', max_length=255, blank=True)
campaign_code = ValidXMLCharField(u'Campaign code', blank=True, max_length=15)
is_anonymous = models.BooleanField(u'anonymous donation')
is_anonymous = models.BooleanField(u'anonymous donation', default=False)
# PayPal
ipn = ValidXMLCharField(u'PayPal IPN', blank=True, null=True, max_length=75)
# Mollie
Expand Down
2 changes: 1 addition & 1 deletion akvo/rsr/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def user_activated_callback(sender, **kwargs):

user = kwargs.get("user", False)
if user:
org = user.get_profile().organisation
org = user.userprofile.organisation
users = User.objects.all()
#find all users that are 1) superusers 2) RSR editors
#3) org admins for the same org as the just activated user
Expand Down
6 changes: 3 additions & 3 deletions akvo/rsr/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def update_user_profile(
template_name,
{
'form': form,
'profile': user.get_profile()
'profile': user.userprofile
},
context_instance=context
)
Expand Down Expand Up @@ -761,7 +761,7 @@ class CommentForm(ModelForm):

class Meta:
model = ProjectComment
exclude = ('time', 'project', 'user', )
fields = ('comment',)


@login_required()
Expand Down Expand Up @@ -889,7 +889,7 @@ def getwidget(request, project, draft=False, can_add_update=False):
'''
if not request.POST:
try:
account_level = request.user.get_profile().organisation.organisationaccount.account_level
account_level = request.user.userprofile.organisation.organisationaccount.account_level
except:
account_level = 'free'
# project = get_object_or_404(Project.objects, pk=project_id)
Expand Down
1 change: 1 addition & 0 deletions akvo/settings/10-base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
see < http://www.gnu.org/licenses/agpl.html >.
"""

ALLOWED_HOSTS = ['*']

#Additional information about a User
AUTH_PROFILE_MODULE = 'rsr.userprofile'
Expand Down
2 changes: 0 additions & 2 deletions akvo/templates/rsr/myakvo/navigation.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{% load i18n %}
{% load i18n permissions_tags %}


<div class="boxbody" style="padding-bottom: 20px;">
{% url 'myakvo' as url_myakvo %}
Expand Down
6 changes: 3 additions & 3 deletions akvo/templates/rsr/project/update_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

{% block breadcrum_items %}
{{block.super}}
<li><a href="{% url project_list 'all' %}"><span>{% trans 'Projects' %}</span></a></li>
<li><a href="{% url project_main project.id %}"><span>{{project.title|truncatewords:3}}</span></a></li>
<li><a href="{% url 'project_list' 'all' %}"><span>{% trans 'Projects' %}</span></a></li>
<li><a href="{% url 'project_main' project.id %}"><span>{{project.title|truncatewords:3}}</span></a></li>
<li id="last_breadcrum_item">
{% if edit_mode %}
{% trans "Edit update" %}
Expand Down Expand Up @@ -194,7 +194,7 @@ <h4>{% trans 'Video credit' %} <span class="small grey">({% trans 'optional' %})
{% if edit_mode %}
<a href="{{ update.get_absolute_url }}" class="small">{% trans 'Cancel' %}</a>
{% else %}
<a href="{% url project_main project.id %}" class="small">{% trans 'Cancel' %}</a>
<a href="{% url 'project_main' project.id %}" class="small">{% trans 'Cancel' %}</a>
{% endif %}
</div>
<a class="aqua awesome" href="" onclick="validateForm(); return false;">
Expand Down
2 changes: 1 addition & 1 deletion akvo/urls/partner_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from __future__ import absolute_import

from django.conf import settings
from django.conf.urls.defaults import patterns, url
from django.conf.urls import patterns, url
from django.conf.urls.i18n import i18n_patterns
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django_counter.urls import urlpatterns as counter_urls
Expand Down
11 changes: 6 additions & 5 deletions scripts/deployment/pip/requirements/2_rsr.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# Django
Django==1.5.5
https://www.djangoproject.com/download/1.7.b4/tarball/#egg=django

# Django apps
django-filter==0.7
django-markup==0.4
django-pagination==1.0.7
django-paypal==0.1.3
django-registration==1.0
django-templatetag-handlebars==1.2.0

sorl-thumbnail==3.2.5

# API framework
mimeparse==0.1.3
python-dateutil==2.2
requests==2.3.0
djangorestframework==2.3.13
django-tastypie==0.11.1

# Django apps from VCS web services
-e git://github.com/akvo/django-counter.git@e437712696fe48771e3142ee000a64abd055ee2a#egg=django-counter
-e git://github.com/akvo/django-counter.git@3b38f45a243970fda1a61124fd6ec8b9bd352c35#egg=django-counter
-e git://github.com/lukeman/django-sorting.git@d3456924ff2140c2a3466a2dd9d674486500393e#egg=django-sorting
-e git://github.com/carlio/djangoembed.git@cc655adb61d3deafe8bedf14ad34a7b7712acdef#egg=djangoembed
-e git://github.com/akvo/djangoembed.git@3a1d6b955bcff4b2ec04eefca79a0b2ebb31289a#egg=djangoembed
-e git://github.com/akvo/django-tastypie.git@781fea26200b741c292cf166b30b7066e9e40f44#egg=django-tastypie
-e git://github.com/akvo/django-registration.git@a586ba92bcf7c373f3c0d94e24edd9a1e312dd16#egg=registration

# Akvonaut apps
-e git://github.com/peeb/django-mollie-ideal.git#egg=mollie
Expand Down
6 changes: 3 additions & 3 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.box = "rsr-dev-20140114"
config.vm.box_url = "http://files.support.akvo-ops.org/rsr-dev-20140114.box"

config.vm.box = "rsr-django-upgrade"
config.vm.box_url = "http://files.support.akvo-ops.org/rsr-dev-django-upgrade-20140527.box"
config.vm.synced_folder "../", "/vagrant/rsr/checkout/"

config.vm.network :private_network, ip: "192.168.50.101"
Expand Down
6 changes: 5 additions & 1 deletion vagrant/provision_vagrant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ sudo -u rsr /var/akvo/rsr/venv/bin/pip install -r /var/akvo/rsr/code/scripts/dep

manage='sudo -u rsr /var/akvo/rsr/venv/bin/python /var/akvo/rsr/code/manage.py'

$manage syncdb --noinput

if [ ! -e /etc/localdev_rsr_provisioned ]
then
/var/akvo/rsr/install_test_db.sh
$manage migrate
echo `date` > /etc/localdev_rsr_provisioned
else
$manage syncdb --noinput
$manage migrate
fi

$manage collectstatic --noinput

# Temporary Hack (see https://github.com/akvo/akvo-provisioning/issues/29)
sudo sed -i 's/SITE_ID=1$/SITE_ID=1004/' /var/akvo/rsr/local_settings.conf

Expand Down

0 comments on commit 26350f3

Please sign in to comment.