Revision 66b454b7
b/cloudcms/clients.py | ||
---|---|---|
10 | 10 |
from datetime import datetime |
11 | 11 |
from lxml import html |
12 | 12 |
|
13 |
from synnefo import settings
|
|
13 |
from django.conf import settings
|
|
14 | 14 |
|
15 | 15 |
CLIENTS_CACHE_TIMEOUT = getattr(settings, 'CLOUDCMS_CLIENTS_CACHE_TIMEOUT', 120) |
16 | 16 |
|
... | ... | |
170 | 170 |
yield source.get_latest() |
171 | 171 |
|
172 | 172 |
|
173 |
|
|
174 |
class PithosXMLSource(VersionSource): |
|
175 |
""" |
|
176 |
Extract version from versioninfo.xml |
|
177 |
""" |
|
178 |
source_type = 'pithos_xml' |
|
179 |
|
|
180 |
def load(self): |
|
181 |
""" |
|
182 |
Extract first item from versioninfo.xml |
|
183 |
""" |
|
184 |
spliturl = urlparse.urlsplit(self.link) |
|
185 |
baseurl = spliturl.geturl().replace(spliturl.path, '') |
|
186 |
html = self.get_url(self.link) |
|
187 |
items = html.xpath("//item") |
|
188 |
|
|
189 |
# helper lambdas |
|
190 |
def _parse_row(row): |
|
191 |
try: |
|
192 |
name = row.find("title").text |
|
193 |
link = row.find("enclosure").attrib["url"] |
|
194 |
strdate = row.find("pubdate").text |
|
195 |
date = datetime.strptime(strdate.split(" +")[0], |
|
196 |
"%a, %d %B %Y %H:%M:%S") |
|
197 |
print "DATE", date |
|
198 |
version = row.find("title").text |
|
199 |
return { |
|
200 |
'name': name, |
|
201 |
'link': link, |
|
202 |
'date': date, |
|
203 |
'version': version |
|
204 |
} |
|
205 |
except Exception, e: |
|
206 |
return None |
|
207 |
|
|
208 |
versions = filter(bool, map(_parse_row, items)) |
|
209 |
self.versions = versions |
|
210 |
return self |
|
211 |
|
|
212 |
|
|
173 | 213 |
# SOURCE TYPES CLASS MAP |
174 | 214 |
SOURCE_TYPES = { |
175 | 215 |
'redmine_files': RedmineSource, |
176 | 216 |
'direct': DirectSource, |
217 |
'pithos_xml': PithosXMLSource, |
|
177 | 218 |
'link': LinkSource |
178 | 219 |
} |
179 |
|
b/cloudcms/models.py | ||
---|---|---|
63 | 63 |
('warning','Warning'), |
64 | 64 |
('info','Info'), |
65 | 65 |
) |
66 |
|
|
66 |
|
|
67 | 67 |
|
68 | 68 |
code = models.CharField('Identifier', max_length=100, null=False, blank=False, |
69 | 69 |
help_text="Just a codename of the application, to be used in "\ |
... | ... | |
92 | 92 |
footer_top = models.TextField(default="", blank=True) |
93 | 93 |
footer_bottom = models.TextField(default="", blank=True) |
94 | 94 |
|
95 |
message_type = models.CharField(max_length=20,
|
|
95 |
message_type = models.CharField(max_length=20, |
|
96 | 96 |
choices= MESSAGE_TYPE_CHOICES, |
97 | 97 |
default = 'NM' ) |
98 | 98 |
custom_message = models.TextField(default="", blank=True) |
99 |
|
|
99 |
|
|
100 | 100 |
@classmethod |
101 | 101 |
def current(cls): |
102 | 102 |
return cls.objects.get(site__pk=settings.SITE_ID) |
... | ... | |
149 | 149 |
source_type = models.CharField(max_length=60, |
150 | 150 |
choices=(('link','Link'), |
151 | 151 |
('direct','Direct'), |
152 |
('pithos_xml','Pithos XML'), |
|
152 | 153 |
('redmine_files','Redmine files'))) |
153 | 154 |
os = models.CharField(max_length=255) |
154 | 155 |
link = models.CharField(max_length=255) |
... | ... | |
179 | 180 |
image_faq = MediaFileForeignKey(MediaFile, blank=True, null=True, related_name='image_faq') |
180 | 181 |
image_userguide = MediaFileForeignKey(MediaFile, blank=True, null=True,related_name='image_userguide') |
181 | 182 |
class_name = models.CharField(_('class name'), max_length=100, blank=True) |
182 |
|
|
183 |
|
|
183 |
|
|
184 |
|
|
184 | 185 |
class Meta: |
185 | 186 |
verbose_name = _('service') |
186 | 187 |
verbose_name_plural = _('services') |
... | ... | |
193 | 194 |
return self.faqs.filter(is_active=True)[0] |
194 | 195 |
except: |
195 | 196 |
return None |
196 |
|
|
197 |
|
|
197 | 198 |
def get_first_entry(self): |
198 | 199 |
try: |
199 | 200 |
return self.userguideentries.filter(is_active=True)[0] |
200 | 201 |
except: |
201 | 202 |
return None |
202 |
|
|
203 |
|
|
203 | 204 |
def __unicode__(self): |
204 | 205 |
trans = translations.TranslatedObjectMixin.__unicode__(self) |
205 | 206 |
return trans or _('Unnamed category') |
... | ... | |
215 | 216 |
cms_page = models.ForeignKey(Page, null=True, blank=True) |
216 | 217 |
title_faq = models.CharField(_('service title (faq section)'), max_length=100, blank=True) |
217 | 218 |
title_userguide = models.CharField(_('service title (userguide section)'), max_length=100, blank=True) |
218 |
|
|
219 |
|
|
219 | 220 |
class Meta: |
220 | 221 |
verbose_name = _('service translation') |
221 | 222 |
verbose_name_plural = _('service translations') |
Also available in: Unified diff