Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have added a .gitignore file for excluding *db and *pyc from git #5

Merged
3 commits merged into from
Sep 16, 2010
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
*.db
Binary file modified Pootle/dbs/pootle.db
Binary file not shown.
Binary file modified Pootle/external_apps/contact_form_i18n/forms.pyc
Binary file not shown.
Binary file modified Pootle/external_apps/contact_form_i18n/urls.pyc
Binary file not shown.
Binary file modified Pootle/external_apps/contact_form_i18n/views.pyc
Binary file not shown.
Binary file modified Pootle/external_apps/djblets/siteconfig/forms.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_app/forms.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_app/views/admin/adminlanguages.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_app/views/admin/adminpages.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_app/views/admin/adminroot.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_app/views/admin/adminusers.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_app/views/index/about.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_app/views/index/index.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_app/views/index/robots.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_language/views.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_notifications/feeds.pyc
Binary file not shown.
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_notifications/views.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_profile/views.pyc
Binary file not shown.
8 changes: 8 additions & 0 deletions Pootle/local_apps/pootle_project/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

import os
import logging

from django.utils.translation import ugettext_lazy as _
from django.db import models
Expand Down Expand Up @@ -167,19 +168,26 @@ def get_treestyle(self):
return "nongnu"

def get_template_translationproject(self):

try:
logging.debug ( "printing templates" )
return self.translationproject_set.get(language__code='templates')
except ObjectDoesNotExist:
try:
logging.debug ( "failed, creating new one" )
return self.translationproject_set.get(language=self.source_language_id)
except ObjectDoesNotExist:
logging.debug ( "failed again, you need to think something" )
pass

def add_language(self, language):
"""
Adds a language as a translation project.
"""
import logging

from pootle_translationproject.models import TranslationProject
logging.debug("Project ID: %s, language id: %s", self.id , language.id)
tp = TranslationProject(project_id = self.id,
language_id = language.id)

Expand Down
Binary file modified Pootle/local_apps/pootle_project/models.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_project/views.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/pootle_terminology/views.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/wt_articles/management/__init__.pyc
Binary file not shown.
Binary file modified Pootle/local_apps/wt_articles/management/commands/__init__.pyc
Binary file not shown.
Binary file not shown.
11 changes: 7 additions & 4 deletions Pootle/local_apps/wt_articles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from BeautifulSoup import BeautifulSoup
from datetime import datetime
import polib
import logging

# Generic relation to mturk_manager
from django.contrib.contenttypes import generic
Expand Down Expand Up @@ -201,10 +202,12 @@ def pootle_project_exists(self):
"""
return len(Project.objects.filter(code = self.get_project_code())) > 0

def source_to_pootle_project(self):
def notusedsource_to_pootle_project(self):
"""
Constructs a Pootle project from the article, if a project doesn't already exist.
"""

logging.debug ( "source_to_pootle_project" )
from pootle_app.models.signals import post_template_update

if self.pootle_project_exists():
Expand All @@ -215,9 +218,9 @@ def source_to_pootle_project(self):

if len(sl_set) < 1:
raise Exception("Language code %s does not exist!" % self.language)

source_language = sl_set[0]

source_language = sl_set[0]
logging.debug ( "source language" + source_language )
# Construct the project
project = Project()
project.fullname = self.get_project_name()
Expand All @@ -226,7 +229,7 @@ def source_to_pootle_project(self):

# Save the project
project.save()

logging.debug ( "project saved")
# Export the article to .po and store in the templates "translation project". This will be used to generate translation requests for other languages.
templatesProject = project.get_template_translationproject()
po = self.sentences_to_po()
Expand Down
Binary file modified Pootle/local_apps/wt_articles/models.pyc
Binary file not shown.
35 changes: 34 additions & 1 deletion Pootle/local_apps/wt_articles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ def source_to_po(request, aid, template_name="wt_articles/source_export_po.html"
}, context_instance=RequestContext(request))

def _source_to_pootle_project(article):
import logging
from django.utils.encoding import smart_str
from pootle_app.models.signals import post_template_update


# Fetch the source_language
sl_set = Language.objects.filter(code = article.language)

Expand All @@ -370,11 +375,39 @@ def _source_to_pootle_project(article):
project.code = project.fullname.replace(" ", "_").replace(":", "_")
# PO filetype
#project.localfiletype = "po" # filetype_choices[0]

project.source_language = source_language
# Save the project
project.save()

# Save the project
templates_language = Language.objects.filter(code='templates')[0]
project.add_language(templates_language)
project.save()


#code copied for wr_articles
logging.debug ( "project saved")
# Export the article to .po and store in the templates "translation project". This will be used to generate translation requests for other languages.
templatesProject = project.get_template_translationproject()
po = article.sentences_to_po()
poFilePath = "%s/article.pot" % (templatesProject.abs_real_path)

oldstats = templatesProject.getquickstats()

# Write the file
with open(poFilePath, 'w') as f:
f.write(smart_str(po.__str__()))

# Force the project to scan for changes.
templatesProject.scan_files()
templatesProject.update(conservative=False)

# Log the changes
newstats = templatesProject.getquickstats()
post_template_update.send(sender=templatesProject, oldstats=oldstats, newstats=newstats)



return project

@login_required
Expand Down
Binary file modified Pootle/local_apps/wt_articles/views.pyc
Binary file not shown.