import api.forms as forms
import api.response as response
from api.utils import validate_form, hglibrary, natural_order
import api.forms as forms
import api.response as response
from api.utils import validate_form, hglibrary, natural_order
def check_user(request, user):
log.info("user: %r, perm: %r" % (request.user, request.user.get_all_permissions()) )
#pull request
if is_prq(user):
def check_user(request, user):
log.info("user: %r, perm: %r" % (request.user, request.user.get_all_permissions()) )
#pull request
if is_prq(user):
yield response.AccessDenied().django_response({
'reason': 'access-denied',
'message': "You don't have enough priviliges to view pull requests."
})
# other users
elif request.user.username != user:
yield response.AccessDenied().django_response({
'reason': 'access-denied',
'message': "You don't have enough priviliges to view pull requests."
})
# other users
elif request.user.username != user:
yield response.AccessDenied().django_response({
'reason': 'access-denied',
'message': "You don't have enough priviliges to view other people's document."
yield response.AccessDenied().django_response({
'reason': 'access-denied',
'message': "You don't have enough priviliges to view other people's document."
log.info("DOCID %s", docid)
doc = lib.document_create(docid)
# document created, but no content yet
log.info("DOCID %s", docid)
doc = lib.document_create(docid)
# document created, but no content yet
try:
doc = doc.quickwrite('xml', data.encode('utf-8'),
'$AUTO$ XML data uploaded.', user=request.user.username)
try:
doc = doc.quickwrite('xml', data.encode('utf-8'),
'$AUTO$ XML data uploaded.', user=request.user.username)
-
- if is_prq(user):
- # source revision, should probably change
- # but there are no changes yet, so...
- pass
-
- except RevisionNotFound, e:
+ elif is_prq(user):
+ prq = prq_for_user(user)
+ # commiter's document
+ prq_doc = lib.document_for_rev(prq.source_revision)
+ doc = prq_doc.take(user)
+ else:
return response.EntityNotFound().django_response({
'reason': 'document-not-found',
'message': e.message,
return response.EntityNotFound().django_response({
'reason': 'document-not-found',
'message': e.message,
return response.EntityNotFound().django_response({
'reason': 'document-not-found',
'message': e.message,
'docid': docid,
return response.EntityNotFound().django_response({
'reason': 'document-not-found',
'message': e.message,
'docid': docid,
if not isinstance(file, unicode):
try:
file = file.decode('utf-8')
if not isinstance(file, unicode):
try:
file = file.decode('utf-8')
# User is not permitted to make a merge, right away
# So we instead create a pull request in the database
try:
# User is not permitted to make a merge, right away
# So we instead create a pull request in the database
try:
"revision": user_doc_new.revision,
'timestamp': user_doc_new.revision.timestamp,
"revision": user_doc_new.revision,
'timestamp': user_doc_new.revision.timestamp,
- "parent_revision": user_doc_new.revision,
- "parent_timestamp": user_doc_new.revision.timestamp,
+ "parent_revision": user_doc.revision,
+ "parent_timestamp": user_doc.revision.timestamp,
"shared_revision": doc_new.revision,
"shared_timestamp": doc_new.revision.timestamp,
"shared_revision": doc_new.revision,
"shared_timestamp": doc_new.revision.timestamp,