Skip to content

Instantly share code, notes, and snippets.

@goldenboy
Forked from rochacbruno/contenttypes.py
Created August 9, 2012 03:42
Show Gist options
  • Save goldenboy/3300755 to your computer and use it in GitHub Desktop.
Save goldenboy/3300755 to your computer and use it in GitHub Desktop.
Movuca content type
class Product(ContentModel):
tablename = "product_data"
def set_properties(self):
ckeditor = CKEditor()
T = current.T
self.fields = [
Field("price", "double", notnull=True, default=0),
Field("manufacturer", "string", notnull=True),
Field("in_stock", "boolean", notnull=True, default=True),
Field("info", "text", notnull=True),
Field("product_size", "string"),
]
self.validators = {
"info": IS_NOT_EMPTY(),
"manufacturer": IS_NOT_EMPTY(),
"product_size": IS_EMPTY_OR(IS_IN_SET([("L", T("Large")),
("M", T("Medium")),
("S", T("Small"))],
zero=None)),
}
self.widgets = {
"info": ckeditor.widget
}
self.labels = {
"price": T("Product Price"),
"manufacturer": T("Manufacturer name or brand"),
"in_stock": T("Available?"),
"info": T("Product specs"),
"product_size": T("Product size"),
}
{{response.files.append(URL('static','basic/js/article_edit.js'))}}
{{extend "basic/app/layout.html"}}
{{=form.custom.begin}}
<div class="row edit-article-wrapper">
<div class="twelve columns alpha">
<fieldset>
<legend>{{=T("The Basics")}}</legend>
{{=customfield(form, 'title')}}
{{=customfield(form, 'description')}}
{{=customfield(form, 'picture')}}
</fieldset>
<fieldset>
<legend>{{=T("Properties")}}</legend>
<div class="five columns alpha">
{{=customfield(form, 'price')}}
{{=customfield(form, 'in_stock')}}
</div>
<div class="five columns omega">
{{=customfield(form, 'manufacturer')}}
{{=customfield(form, 'product_size')}}
</div>
</fieldset>
<fieldset>
<legend>{{=T("Specifications")}}</legend>
{{=customfield(form, 'info')}}
</fieldset>
</div>
<div class="four columns omega">
<fieldset>
<legend>{{=T("Category & Tags")}}</legend>
{{=customfield(form, 'category_id')}}
{{=customfield(form, 'tags')}}
</fieldset>
<fieldset>
<legend>{{=T("options")}}</legend>
{{=customfield(form, 'privacy')}}
{{=customfield(form, 'license')}}
</fieldset>
<fieldset>
<legend>{{=T("Save")}}</legend>
{{=customfield(form, 'draft')}}
<br />
<button class="full-width" id="publish">{{=T("Publish")}}</button>
<button class="full-width" id="draft">{{=T("Save as a draft")}}</button>
</fieldset>
</div>
</div>
{{=form.custom.end}}
{{response.files.append(URL('static','basic/css/jqModal.css'))}}
{{response.files.append(URL('static','basic/js/jqModal.js'))}}
{{response.files.append(URL('static','basic/js/article_show.js'))}}
{{extend "basic/app/layout.html"}}
<style>
.product-information ul{
padding-left:5px;
}
.product-information li {
border: 1px solid #fff;
list-style: none;
padding: 5px;
background-color:#F5F5F5;
}
.product-information button {
width:100%;
}
.product-label {
color:blue;
}
</style>
<div class="twelve columns center show-article-wrapper">
<div class="row show-article-meta">
<div class="two columns alpha article-author-picture">
{{=A(IMG(_src=get_image(article.author.thumbnail, 'user'), _width=90, _height=90), _href=CURL('person','show', args=article.author.nickname or article.author))}}
</div>
<div class="ten columns omega">
{{=A(H3(article.title, _class="list-article-title"), _href=CURL('article', 'show', args=[article.id, article.slug]))}}
<em>{{=T(article.content_type_id.title)}} {{=T("by")}} {{=A("%(first_name)s %(last_name)s (%(nickname)s)" % article.author, _href=CURL('person','show', args=article.author.nickname or article.author))}} {{=T('on')}} {{=ftime(article.publish_date)}} </em>
{{if article.category_id:}}
<em>{{=T('in')}} {{=A(article.category_id.name, _href=CURL('article', 'list', vars=dict(category=article.category_id.name.replace(' ','_'))))}}</em>
{{pass}}
<div class="show-article-information" id="links">
{{=action_links}}
</div>
</div>
</div>
<div class="row show-article-content">
<div class="twelve columns alpha">
<div class="show-article-description article-box">
{{=H5(T("Product Description"))}}
{{=article.description}}
</div>
</div>
<div class="eight columns alpha">
<div class="jqmWindow" id="photomodal">
<a href='#' class="jqmClose">{{=T("Close")}}</a>
<br />
<img class="photo jqmClose" src="{{=URL('static','images',args='blank.gif')}}" />
</div>
{{=IMG(_src=get_image(article.picture, article.content_type_id.identifier),_id=article.picture,_class="eight columns alpha")}}
<div class="row show-article-tags">
{{if article.tags:}}
<img src="{{=URL('static','%s/images/icons' % theme_name, args='tag_rounded.24.png')}}" alt="{{=T('Tags')}}" title="{{=T('Tags')}}"><em>{{=tagfy(article.tags)}} </em>
{{pass}}
</div>
</div>
<div class="four columns omega product-information">
<!-- Lockerz Share BEGIN -->
<ul>
<li>
<div class="a2a_kit a2a_default_style product-share">
<a class="a2a_dd" href="http://www.addtoany.com/share_save">Share</a>
<span class="a2a_divider"></span>
<a class="a2a_button_facebook"></a>
<a class="a2a_button_twitter"></a>
<a class="a2a_button_email"></a>
<a class="a2a_button_google_gmail"></a>
<a class="a2a_button_google_plus"></a>
<a class="a2a_button_tumblr"></a>
</div>
</li>
</ul>
<script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>
<!-- Lockerz Share END -->
{{sizes = dict([("L", T("Large")),("M", T("Medium")), ("S", T("Small"))])}}
{{article_data.fproduct_size = sizes[article_data.product_size]}}
{{article_data.fprice = "$ %.2f" % article_data.price}}
{{fields=[(T("Product Size"),'product_size'), (T("Manufacturer"),'manufacturer'), (T("In Stock"),'in_stock'), (T("Price"),'fprice')]}}
{{=UL(*[LI(SPAN(label, _class="product-label"),": ",article_data[field]) for label,field in fields])}}
<ul>
<li id="buybutton">
<button onclick="ACTION TO BUY THE PRODUCT">{{=T("Buy")}}</button>
</li>
</ul>
</div>
<div class="seven columns omega product-instructions article-box">
{{=H5(T("Specifications"))}}
{{=XML(article_data.info)}}
</div>
</div>
<div class="row show-article-related article-box">
{{if related_articles:}}
<h4><img src="{{=URL('static','%s/images/icons' % theme_name, args='attach_round.24.png')}}" alt="{{=T('Related articles')}}" title="{{=T('Related articles')}}">{{=T("Related articles")}}</h4>
{{=related_articles}}
{{pass}}
</div>
<div class="row show-article-comments article-box">
{{=comments}}
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment