try:
lock = lib.lock()
try:
- print "DOCID", docid
-
+ print "DOCID", docid
doc = lib.document_create(docid)
# document created, but no content yet
--- /dev/null
+# -*- encoding: utf-8 -*-
+
+__author__= "Ćukasz Rekucki"
+__date__ = "$2009-09-25 15:49:50$"
+__doc__ = "Module documentation."
+
+from piston.handler import BaseHandler, AnonymousBaseHandler
+
+from explorer.models import PullRequest
+
+class PullRequestListHandler(BaseHandler):
+ allowed_methods = ('GET',)
+
+ def read(self, request):
+ if request.user.has_perm('explorer.book.can_share'):
+ return PullRequest.objects.all()
+ else:
+ return PullRequest.objects.filter(commiter=request.user)
+
+
+class PullRequestHandler(BaseHandler):
+ allowed_methods = ('GET',)
+
+ def read(self, request, prq_id):
+ return PullRequest.objects.get(id=prq_id)
\ No newline at end of file
--- /dev/null
+#!/usr/bin/env python
+# -*- conding: utf-8 -*-
+__author__="lreqc"
+__date__ ="$2009-09-08 14:31:26$"
+
+from django.core.management.base import BaseCommand
+from django.utils import simplejson as json
+from django.test.client import Client
+from django.core.urlresolvers import reverse
+
+from optparse import make_option
+
+class Command(BaseCommand):
+
+ option_list = BaseCommand.option_list + (
+ make_option('-u', '--user', action='store', dest='username'),
+ make_option('-p', '--password', action='store', dest='password'),
+ )
+
+ def handle(self, *args, **options):
+ client = Client()
+ if not options['username'] or not options['password']:
+ raise CommandError("You must provide login data")
+
+ client.login(username=options['username'], \
+ password=options['password'])
+
+ print options['username'], options['password']
+
+ docid = args[0]
+
+ url = reverse("document_view", args=[docid])
+ print "Quering %s" % url
+ resp = client.get(url)
+
+ result = json.loads(resp.content)
+ print result
+
+ print "Current revision for '%s': %s" % (docid, result['user_revision'])
+ url = reverse("docmerge_view", args=[docid])
+ print "Sending POST to %s" % url
+ resp = client.post(url, {
+ 'type': 'share',
+ 'target_revision': result['user_revision'],
+ 'message': 'Sharing.. :)'
+ })
+
+ print resp.status_code, resp.content
--- /dev/null
+#!/usr/bin/env python
+# -*- conding: utf-8 -*-
+__author__="lreqc"
+__date__ ="$2009-09-08 14:31:26$"
+
+from django.core.management.base import BaseCommand
+from django.utils import simplejson as json
+from django.test.client import Client
+from django.core.urlresolvers import reverse
+
+from optparse import make_option
+
+class Command(BaseCommand):
+
+ option_list = BaseCommand.option_list + (
+ make_option('-u', '--user', action='store', dest='username'),
+ make_option('-p', '--password', action='store', dest='password'),
+ )
+
+ def handle(self, *args, **options):
+ client = Client()
+ if not options['username'] or not options['password']:
+ raise CommandError("You must provide login data")
+
+ client.login(username=options['username'], \
+ password=options['password'])
+
+ print options['username'], options['password']
+
+ filename = args[0]
+ docid = args[1]
+
+ url = reverse("document_view", args=[docid])
+ print "Quering %s" % url
+ resp = client.get(url)
+
+ result = json.loads(resp.content)
+ print result
+
+ print "Current revision for '%s': %s" % (docid, result['user_revision'])
+ url = reverse("doctext_view", args=[ docid, result['user_revision'] ])
+ print "Sending PUT to %s" % url
+
+ resp = client.put(url, {
+ 'contents': open(filename).read(),
+ 'message': options['message'] or ''
+
+ })
+
+ print resp.status_code, resp.content
--- /dev/null
+#!/usr/bin/env python
+# -*- conding: utf-8 -*-
+__author__="lreqc"
+__date__ ="$2009-09-08 14:31:26$"
+
+from django.core.management.base import BaseCommand
+from django.utils import simplejson as json
+from django.test.client import Client
+from django.core.urlresolvers import reverse
+
+from optparse import make_option
+
+class Command(BaseCommand):
+
+ option_list = BaseCommand.option_list + (
+ make_option('-u', '--user', action='store', dest='username'),
+ make_option('-p', '--password', action='store', dest='password'),
+ make_option('-m', '--message', action='store', dest='message'),
+ )
+
+ def handle(self, *args, **options):
+ client = Client()
+ if not options['username'] or not options['password']:
+ raise CommandError("You must provide login data")
+
+ client.login(username=options['username'], \
+ password=options['password'])
+
+ print options['username'], options['password']
+
+ filename = args[0]
+ docid = args[1]
+
+ url = reverse("document_view", args=[docid])
+ print "Quering %s" % url
+ resp = client.get(url)
+
+ result = json.loads(resp.content)
+ print result
+
+ print "Current revision for '%s': %s" % (docid, result['user_revision'])
+ url = reverse("doctext_view", args=[ docid, result['user_revision'] ])
+ print "Sending PUT to %s" % url
+
+ resp = client.put(url, {
+ 'contents': open(filename).read(),
+ 'message': options['message'] or ''
+
+ })
+
+ print resp.status_code, resp.content
--- /dev/null
+#!/usr/bin/env python
+# -*- conding: utf-8 -*-
+__author__="lreqc"
+__date__ ="$2009-09-08 14:31:26$"
+
+from django.core.management.base import BaseCommand
+from django.utils import simplejson as json
+from django.test.client import Client
+from django.core.urlresolvers import reverse
+
+from optparse import make_option
+
+class Command(BaseCommand):
+
+ option_list = BaseCommand.option_list + (
+ make_option('-u', '--user', action='store', dest='username'),
+ make_option('-p', '--password', action='store', dest='password'),
+ make_option('-d', '--dublin-core', action='store_true', dest='dc'),
+ )
+
+ def handle(self, *args, **options):
+ client = Client()
+ if not options['username'] or not options['password']:
+ raise CommandError("You must provide login data")
+
+ client.login(username=options['username'], \
+ password=options['password'])
+
+ print options['username'], options['password']
+
+ filename = args[0]
+ bookname = args[1]
+
+ print "Uploading '%s' as document '%s'" % (filename, bookname)
+ print "Wth DC template" if options['dc'] else ""
+
+ print client.post( reverse("document_list_view"),\
+ {
+ 'bookname': bookname,
+ 'ocr_file': open(filename),
+ 'generate_dc': options['dc'] } )
+
document = models.CharField(max_length=255)
# revision to be merged into the main branch
- source_revision = models.CharField(max_length=40)
+ source_revision = models.CharField(max_length=40, unique=True)
# current status
status = models.CharField(max_length=1, choices=REQUEST_STATUSES)
response_comment = models.TextField(blank=True)
# revision number in which the changes were merged (if any)
- merged_rev = models.CharField(max_length=40, blank=True, null=True)
+ merged_rev = models.CharField(max_length=40, blank=True, null=True)
+
+
+ def __unicode__(self):
+ return unicode(self.comitter) + u':' + self.document
def get_image_folders():
return sorted(fn for fn in os.listdir(os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR)) if not fn.startswith('.'))