This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateWithUserMixin(object): | |
def create(self, request, *args, **kwargs): | |
if request.DATA.get('user') is None: | |
request.DATA['user'] = request.user.pk | |
if request.DATA.get('last_changed_by') is None: | |
request.DATA['last_changed_by'] = request.user.pk | |
return super(CreateWithUserMixin, self).create(request, *args, **kwargs) | |
class UpdateWithUserMixin(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.controller('LoginController', function($scope, $http, $location) { | |
$scope.login = function (){ | |
$http.post('/accounts/login/', { | |
'email': $scope.email, | |
'password': $scope.password | |
}) | |
.success(function(data, status, headers, config) { | |
$location.reload(); | |
}). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="clearfix"> | |
<form class="login pull-left"> | |
<h3>Вход</h3> | |
<ul class="phones"> | |
<li ng-repeat="error in errors"> | |
{{error}} | |
</li> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@login_required | |
def getQuestions(request): | |
if request.method == 'GET': | |
session_hash = request.GET['session_hash'] | |
categories = Category.objects.all() | |
myQuestions = SessionQuestion.objects.filter(session_hash_id=session_hash) | |
questionSessionIds = [] | |
response = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
urlpatterns = patterns('', | |
url(r'^(?P<building_pk>\d+)/milestones/$', BuildingMilestoneList.as_view(), name='building-milestone-list'), | |
url(r'^(?P<building_pk>\d+)/categories/$', CategoryList.as_view(), name='building-category-list'), | |
url(r'^milestones/(?P<pk>\d+)/$', BuildingMilestoneDetail.as_view(), name='building-milestone-detail'), | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from haystack.query import SearchQuerySet | |
from rest_framework import filters | |
class AutocompleteFilterBackend(filters.BaseFilterBackend): | |
def filter_queryset(self, request, queryset, view): | |
autocomplete = request.GET.get('q') | |
if autocomplete: | |
sqs = SearchQuerySet().filter(autocomplete=autocomplete) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive('remoteForm', function($http){ | |
function link(scope, formElement, attrs, formController) { | |
scope.input = {}; | |
scope.submit = function (){ | |
$http.post(attrs.remoteForm, scope.input) | |
.success(function(data, status, headers, config) { | |
// $window.location.reload(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form remote-form="/accounts/register/" class="register pull-left"> | |
<h3>Регистрация</h3> | |
<div ng-repeat="error in errors.non_field_errors" class="alert alert-danger fade in"> | |
{{ error }} | |
</div> | |
<div class="form-group"> | |
<label>Имя</label> | |
<input remote-form-control="input.first_name" type="text" name="first_name" class="form-control"/> | |
</div> | |
<div class="form-group"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PatentsApiTestCase(TestCase): | |
def setUp(self): | |
call_command('syncdb') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrganizationContactSerializer(ContactSerializer): | |
organization = serializers.PrimaryKeyRelatedField(queryset=Organization.objects.all(), source='content_object') | |
class Meta: | |
model = Contact | |
fields = 'id', 'organization', 'relation', 'type', 'email', 'first_name', 'last_name', 'legal_entity_name', \ | |
'postal_code', 'region', 'country', 'role', 'to_user' |
OlderNewer