Skip to content

Commit

Permalink
[#790] Merged with feature/rsr_v3
Browse files Browse the repository at this point in the history
  • Loading branch information
kardan committed Oct 10, 2014
2 parents 3abae7b + db60987 commit c209023
Show file tree
Hide file tree
Showing 20 changed files with 350 additions and 114 deletions.
2 changes: 2 additions & 0 deletions akvo/rest/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .budget_item_label import BudgetItemLabelSerializer
from .category import CategorySerializer
from .country import CountrySerializer
from .employment import EmploymentSerializer
from .focus_area import FocusAreaSerializer
from .goal import GoalSerializer
from .internal_organisation_id import InternalOrganisationIDSerializer
Expand All @@ -35,6 +36,7 @@
'BudgetItemLabelSerializer',
'CategorySerializer',
'CountrySerializer',
'EmploymentSerializer',
'FocusAreaSerializer',
'GoalSerializer',
'InternalOrganisationIDSerializer',
Expand Down
20 changes: 20 additions & 0 deletions akvo/rest/serializers/employment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.

from rest_framework import serializers

from akvo.rsr.models import Employment

from .rsr_serializer import BaseRSRSerializer


class EmploymentSerializer(BaseRSRSerializer):

organisation_name = serializers.Field(source='organisation.name')
country_name = serializers.Field(source='country.name')

class Meta:
model = Employment
6 changes: 3 additions & 3 deletions akvo/rest/serializers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@

class UserSerializer(BaseRSRSerializer):
# Needed to show only the first organisation of the user
organisation = OrganisationExtraSerializer(source='first_organisation')
organisation = OrganisationExtraSerializer(source='first_organisation', required=False)

class Meta:
model = get_user_model()
fields = (
'first_name',
'last_name',
'email',
'organisation',
'organisations',
# 'organisation',
# 'organisations',
)
exclude = ('absolute_url',)

Expand Down
1 change: 1 addition & 0 deletions akvo/rest/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
router.register(r'budget_item_label', views.BudgetItemLabelViewSet)
router.register(r'category', views.CategoryViewSet)
router.register(r'country', views.CountryViewSet)
router.register(r'employment', views.EmploymentViewSet)
router.register(r'focus_area', views.FocusAreaViewSet)
router.register(r'goal', views.GoalViewSet)
router.register(r'internal_organisation_id', views.InternalOrganisationIDViewSet)
Expand Down
2 changes: 2 additions & 0 deletions akvo/rest/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .budget_item_label import BudgetItemLabelViewSet
from .category import CategoryViewSet
from .country import CountryViewSet
from .employment import EmploymentViewSet
from .focus_area import FocusAreaViewSet
from .goal import GoalViewSet
from .internal_organisation_id import InternalOrganisationIDViewSet
Expand All @@ -36,6 +37,7 @@
'BudgetItemLabelViewSet',
'CategoryViewSet',
'CountryViewSet',
'EmploymentViewSet',
'FocusAreaViewSet',
'GoalViewSet',
'InternalOrganisationIDViewSet',
Expand Down
18 changes: 18 additions & 0 deletions akvo/rest/views/employment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import Employment

from ..serializers import EmploymentSerializer
from ..viewsets import BaseRSRViewSet


class EmploymentViewSet(BaseRSRViewSet):
"""
"""
queryset = Employment.objects.all()
serializer_class = EmploymentSerializer
18 changes: 16 additions & 2 deletions akvo/rsr/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from registration.models import RegistrationProfile

from .models import Organisation
from .models import Country, Organisation

class RegisterForm(forms.Form):
email = forms.EmailField(
Expand Down Expand Up @@ -165,7 +165,21 @@ class UserOrganisationForm(forms.Form):
organisation = forms.ModelChoiceField(
queryset=Organisation.objects.all(),
label='',
initial='Organisation'
empty_label='Organisation'
)
job_title = forms.CharField(
label='',
required=False,
max_length=50,
widget=forms.TextInput(
attrs={'placeholder': 'Job title (optional)'}
),
)
country = forms.ModelChoiceField(
queryset=Country.objects.all(),
label='',
required=False,
empty_label='Country (optional)'
)

def __init__(self, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions akvo/rsr/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from .budget_item import BudgetItem, BudgetItemLabel, CountryBudgetItem
from .country import Country, RecipientCountry
from .category import Category
from .employment import Employment
from .focus_area import FocusArea
from .goal import Goal
from .indicator import Indicator, IndicatorPeriod
Expand Down Expand Up @@ -57,7 +58,6 @@
from .sector import Sector
from .transaction import Transaction
from .user import User
# from .user_profile import UserProfile

__all__ = [
'Benchmark',
Expand All @@ -68,6 +68,7 @@
'Country',
'RecipientCountry',
'Category',
'Employment',
'FocusArea',
'Goal',
'Indicator',
Expand Down Expand Up @@ -102,7 +103,6 @@
'Sector',
'Transaction',
'User',
# 'UserProfile',
]

# signals!
Expand Down
18 changes: 12 additions & 6 deletions akvo/rsr/static/rsr/v3/css/src/main.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Hack for full-width columns below 570px */
@media (max-width: 570px) {
.col-ts-12 {
@media (max-width: 570px) {
.col-ts-12 {
float: none;
width: 100%;
}
Expand All @@ -23,14 +23,20 @@ body > .navbar {
padding: 4px 9px;
}
.navbar-brand {
width: 150px;
width: 122px;
background-image: url(../../img/logo.png);
background-size: contain;
background-repeat: no-repeat;
text-indent: -999px;
margin-top: 7px;
height: 33px;
margin-left: 0;
margin-top: 11px;
margin-left: 15px;
height: 27px;
padding: 0;
}
@media (min-width: 768px) {
body > .navbar >.container .navbar-brand {
margin-left: 0;
}
}

/* FOOTER */
Expand Down
41 changes: 5 additions & 36 deletions akvo/rsr/views/my_rsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,9 @@
from django.template import RequestContext


def myrsr(request):
@login_required
def my_details(request):
context = RequestContext(request)
if request.is_ajax() and request.method == "POST":
if 'email' in request.POST:
profileForm = ProfileForm(data=request.POST)
if profileForm.is_valid():
profileForm.save(request)
message = {'status': "success",
'message': "Your profile is updated"}
elif profileForm.errors:
message = {'status': "danger",
'message': [v for k, v in profileForm.errors.items()]}
elif 'old_password' in request.POST:
passwordForm = PasswordForm(data=request.POST, request=request)
if passwordForm.is_valid():
passwordForm.save(request)
message = {'status': "success",
'message': "Updated your password"}
elif passwordForm.errors:
message = {'status': "danger",
'message': [v for k, v in passwordForm.errors.items()]}
elif 'organisation' in request.POST:
organisationForm = UserOrganisationForm(data=request.POST,
request=request)
if organisationForm.is_valid():
organisationForm.save(request)
message = {'status': "success",
'message': "You are now linked to organisation"}
elif organisationForm.errors:
message = {'status': "danger",
'message': [v for k, v in organisationForm.errors.items()]}

return HttpResponse(json.dumps(message))

profileForm = ProfileForm(
initial={
Expand All @@ -60,17 +30,16 @@ def myrsr(request):
organisationForm = UserOrganisationForm()

return render_to_response(
'myrsr/myrsr.html',
'myrsr/my_details.html',
{
'profileform': profileForm,
'organisationform': organisationForm,
# 'message': message,
# 'error_message': error_message
'organisationform': organisationForm
},
context_instance=context
)


@login_required
def password_change(request):
context = RequestContext(request)
if request.is_ajax() and request.method == "POST":
Expand Down
10 changes: 6 additions & 4 deletions akvo/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@

{# CSS #}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

{# jQuery #}
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

{% compressed_css 'rsr_v3_style' %}
{% compressed_js 'rsr_v3_libraries' %}

<!-- Piwik -->
{% tracking_code %}
Expand All @@ -33,9 +39,5 @@

{% include 'navigation/footer.html' %}

{# JS #}
<script src="http://fb.me/react-0.10.0.js"></script>
{% compressed_js 'rsr_v3_libraries' %}

</body>
</html>
Loading

0 comments on commit c209023

Please sign in to comment.