From: Łukasz Rekucki Date: Sat, 26 Sep 2009 19:12:41 +0000 (+0200) Subject: Missing files. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/ac2e9ceea7cf6a59810081d52b64d9c22861c62d?ds=sidebyside;hp=--cc Missing files. --- ac2e9ceea7cf6a59810081d52b64d9c22861c62d diff --git a/apps/api/handlers/library_handlers.py b/apps/api/handlers/library_handlers.py index 6fd7786f..86aef21b 100644 --- a/apps/api/handlers/library_handlers.py +++ b/apps/api/handlers/library_handlers.py @@ -70,8 +70,7 @@ class LibraryHandler(BaseHandler): try: lock = lib.lock() try: - print "DOCID", docid - + print "DOCID", docid doc = lib.document_create(docid) # document created, but no content yet diff --git a/apps/api/handlers/manage_handlers.py b/apps/api/handlers/manage_handlers.py new file mode 100644 index 00000000..96159582 --- /dev/null +++ b/apps/api/handlers/manage_handlers.py @@ -0,0 +1,25 @@ +# -*- 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 diff --git a/apps/api/management/commands/doc_share.py b/apps/api/management/commands/doc_share.py new file mode 100644 index 00000000..cf454c53 --- /dev/null +++ b/apps/api/management/commands/doc_share.py @@ -0,0 +1,48 @@ +#!/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 diff --git a/apps/api/management/commands/doc_update.py b/apps/api/management/commands/doc_update.py new file mode 100644 index 00000000..525bb4a8 --- /dev/null +++ b/apps/api/management/commands/doc_update.py @@ -0,0 +1,50 @@ +#!/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 diff --git a/apps/api/management/commands/doc_update_text.py b/apps/api/management/commands/doc_update_text.py new file mode 100644 index 00000000..167db64f --- /dev/null +++ b/apps/api/management/commands/doc_update_text.py @@ -0,0 +1,51 @@ +#!/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 diff --git a/apps/api/management/commands/doc_upload.py b/apps/api/management/commands/doc_upload.py new file mode 100644 index 00000000..66ef9243 --- /dev/null +++ b/apps/api/management/commands/doc_upload.py @@ -0,0 +1,42 @@ +#!/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'] } ) + diff --git a/apps/explorer/models.py b/apps/explorer/models.py index f2dc8f4a..6d8cd8e0 100644 --- a/apps/explorer/models.py +++ b/apps/explorer/models.py @@ -78,7 +78,7 @@ class PullRequest(models.Model): 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) @@ -87,7 +87,11 @@ class PullRequest(models.Model): 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('.'))