Like message programmatically - message

I need to like a message from website, i tried below code in controller file,
#http.route(["/web/like/comment"])
def likemsg(self):
cr,uid = request.cr,request.uid
pool = request.registry
obj_msg = pool['mail.message']
obj_mg.create(cr,uid,{'vote_user_ids':[(4, 0, uid)]})
i don't know how to pass msg_id in create method?

Finally i got solution:
obj_msg.write(cr,uid,[msg_id],{'vote_user_ids':[(4,uid)]})

Related

Adding new elements to a table that has already been saved

So, I am working on a premium code system where you can input a secret code and if the code is valid, it will reward you based on what code you have used. Pretty simple idea, however, I have some trouble with it.
I have a table with all the codes that looks something like this:
GameState.PremiumCodesTable = GameState.PremiumCodesTable or {{code = "X45", value = 30}, {code = "MM4", value = 45}, {code = "B47", value = 100}}
Basically, if the game runs for the first time, the GameState.PremiumCodesTable will be nil and it will create new element in GameState table which is this table: {{code = "X45", value = 30}, {code = "MM4", value = 45}, {code = "B47", value = 100}}
Now, when the user uses the valid code, it gets deleted from the table. Eventually the user will find all the codes, use them and the GameState.PremiumCodesTable table will be empty.
Now, I want to update the game and bring in some new codes to find. However, since the GameState.PremiumCodesTable is already empty and saved, it will always be empty.
How can I add more codes later on?
I have a solution, but I don't like it, so I am asking here. My solution is to add code by code like so:
GameState.PremiumCodesTable[1] = GameState.PremiumCodesTable[1] or {code = "X45", value = 30}
GameState.PremiumCodesTable[2] = GameState.PremiumCodesTable[2] or {code = "MM4", value = 45}
GameState.PremiumCodesTable[3] = GameState.PremiumCodesTable[3] or {code = "B47", value = 100}
and so on... However, this takes too much space, so I'd like it to have in only ONE big table like the one above.
Use the save file to store an array of code strings that have been used, then initialize PremiumCodesTable to contain full data for all of the codes. That way, the save file keeps the bare minimum amount of information, and you get maximum freedom to process the save file however you want. (You may need to store the code data in a non-array table to make it easier to access.)
GameState.usedCodes = GameState.usedCodes or {}
local PremiumCodesTable = {
{code = "X45", value = 30},
{code = "MM4", value = 45},
{code = "B47", value = 100}
}

Zend framework 2 return the view contents as string

In zf1, I could just do this:
$jsonData['html'] = $this->view
->render('search/partials/search-results-list.phtml');
$this->view->jsonData = $jsonData;
$this->getHelper('viewRenderer')->setRender('index-json');
$this->getHelper('layout')->disableLayout();
I tried the code below in zf2 but returns nothing on the $jsonData['html'].
$viewVar = array('some variables to be passed here');
$partial = $this->getServiceLocator()->get('viewhelpermanager')->get('partial');
$html = 'search/partials/search-results-list.phtml';
$jsonData['html'] = $partial($html, $viewVar);
return new JsonModel($jsonData);
What would be the equivalent of this in zf2?
Thanks in advance
You could pass your view to the PHP View Renderer's render method:
https://github.com/zendframework/zf2/blob/master/library/Zend/View/Renderer/PhpRenderer.php#L446

Why JAX-WS generates wrapper for all method arguments?

I am trying to generate web service interface using jax-ws, but i am getting a methods with wrapper class for all arguments instead of arguments list. For example:
#SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
#WebResult(name = "ResendControlsToDmiResponse", targetNamespace = "http://tempuri.org/", partName = "parameters")
#WebMethod(operationName = "ResendControlsToDmi", action = "http://tempuri.org/ResendControlsToDmi")
#Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "2014-01-30T16:01:26.266+02:00")
public ResendControlsToDmiResponse resendControlsToDmi(
#WebParam(partName = "parameters", name = "ResendControlsToDmiData", targetNamespace = "http://tempuri.org/")
ResendControlsToDmiData parameters
);
Can't understand why it's happening and how to generate method with corredct signature.
There rules about the naming of the part elements as they related to the operation name. In your case, it looks like the operation is named resendControlsToDmi, but the incoming data part/element is named ResendControlsToDmiData. Remove the Data off the end of that and it may change. The response element is properly ResendControlsToDmiResponse.

RightFax 10.0 Integration With C#

If I insert the values into the corresponding tables of RightFax, does it FAX automatically or do i need to write the following code for that?
RFCOMAPILib.FaxServerClass faxserver = new RFCOMAPILib.FaxServerClass();
faxserver.ServerName = "ServerName";
faxserver.Protocol = RFCOMAPILib.CommunicationProtocolType.cpNamedPipes;
faxserver.UseNTAuthentication = RFCOMAPILib.BoolType.True;
faxserver.OpenServer();
RFCOMAPILib.Fax fax = (RFCOMAPILib.Fax) faxserver.get_CreateObject(RFCOMAPILib.CreateObjectType.coFax);
// set up your 'fax' object the way you want it, below is just some sample options
fax.ToName = "John Doe";
fax.ToFaxNumber = "4255551111";
fax.ToVoiceNumber = "4255550000";
fax.ToCompany = "ACME";
fax.FromName = "My Company";
fax.FromVoiceNumber = "4255552222";
fax.Send();
Can you please provide me sample code for attachments? If RightFax sends the FAX automatically then which tables do I need to fill-in in order to do that?
Thanks
the below code is vb.net but will show you how to send a fax and add attachment as well, hope this helps. I've written a post about this here but here's the code below ....
Dim FaxAPI As RFCOMAPILib.FaxServer
Dim fFax As RFCOMAPILib.Fax
FaxAPI = New RFCOMAPILib.FaxServer
FaxAPI.ServerName =something
FaxAPI.Protocol = RFCOMAPILib.CommunicationProtocolType.cpTCPIP
FaxAPI.UseNTAuthentication = RFCOMAPILib.BoolType.False
FaxAPI.AuthorizationUserID = something
FaxAPI.AuthorizationUserPassword = something
FaxAPI.OpenServer()
fFax = FaxAPI.CreateObject(RFCOMAPILib.CreateObjectType.coFax)
fFax.Attachments.Add(“D:\FilePickupIn\2222222222-20110322142718-01.tif”)
fFax.HasCoversheet = RFCOMAPILib.BoolType.False
fFax.ToFaxNumber = something
fFax.ToName = something
fFax.Send()
FaxAPI.CloseServer()
FaxAPI = Nothing
fFax = Nothing
happy to help if you get stuck with anything...

Django-Admin Exception Value: 'DeclarativeFieldsMetaclass' object is not iterable

I have one form in forms.py
class EmailForm(forms.Form):
recipient = forms.CharField(max_length=14, min_length=12,
widget=forms.TextInput(attrs=require))
message = forms.CharField(max_length=140, min_length=1,
widget=forms.Textarea(attrs={'cols': 30, 'rows': 5}))
and my site url is
admin.autodiscover()
urlpatterns = patterns('', (r'^admin/(.*)',
include(admin.site.urls)),)
now I want it to be shown on admin interface
I tried so far
First attempt
from myapps.forms import EmailForm
class EmailAdmin(admin.ModelAdmin):
form = EmailForm
did not work Exception Value:
'DeclarativeFieldsMetaclass' object is not iterable
Second attempt
and now I followed http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri...
but could not get help
class EmailAdmin(admin.ModelAdmin):
def my_view(self,request):
return admin_my_view(request,self)
def get_urls(self):
urls = super(SmsAdmin, self).get_urls()
my_urls = patterns('',(r'^my_view/
$',self.admin_site.admin_view(self.my_view)))
return my_urls + urls
def admin_my_view(request, model_admin):
opts = model_admin.model._meta
admin_site = model_admin.admin_site
has_perm = request.user.has_perm(opts.app_label \
+ '.' + opts.get_change_permission())
context = {'admin_site': admin_site.name,
'title': "My Custom View",
'opts': opts,
'root_path': '/%s' % admin_site.root_path,
'app_label': opts.app_label,
'has_change_permission': has_perm}
template = 'admin/demo_app/admin_my_view.html'
return render_to_response(template,
context,context_instance=RequestContext(request))
admin.site.register(EmailForm,EmailAdmin)
and when I run server and type on browser localhost:8000/admin
and hit enter button
Exception Value:
'DeclarativeFieldsMetaclass' object is not iterable
and second time just after first time when I again enter then it show
me the admin page but I can't see my EmailAdmin in admin interface..
Just help me or suggest me any link.
Thanks
(This is my attempt at reformatting your model code):
class EmailForm(forms.Form):
recipient = forms.CharField(max_length=14, min_length=12,
widget=forms.TextInput(attrs=require))
message = forms.CharField(max_length=140, min_length=1,
widget=forms.Textarea(attrs={'cols': 30, 'rows': 5}))
I would put my money on the bit that says "attrs=require" -- if that's not a typo.
What you want instead is something like this:
recipient = forms.CharField(max_length=14, min_length=12,
widget=forms.TextInput(), required=True)

Resources