Search Results

Search found 256 results on 11 pages for 'julien garcia'.

Page 7/11 | < Previous Page | 3 4 5 6 7 8 9 10 11  | Next Page >

  • Django Admin drop down combobox and assigned values

    - by Daniel Garcia
    I have several question for the Django Admin feature. Im kind of new in Django so im not sure how to do it. Basically what Im looking to do is when Im adding information on the model. Some of the fields i want them to be drop-downs and maybe combo-boxes with AutoCompleteMode. Also looking for some fields to have the same information, for example if i have a datatime field I want that information to feed the fields day, month and year from hoti.hotiapp.models import Occurrence from django.contrib import admin class MyModelAdmin(admin.ModelAdmin): exclude = ['reference',] admin.site.register(Occurrence, MyModelAdmin) Anything helps Thanks in advance

    Read the article

  • How to get the cursor position in bash ?

    - by Julien Nicoulaud
    In a bash script, I want to get the cursor column in a variable. It looks like using the ANSI escape code {ESC}[6n is the only way to get it, for example the following way: # Query the cursor position echo -en '\033[6n' # Read it to a variable read -d R CURCOL # Extract the column from the variable CURCOL="${CURCOL##*;}" # We have the column in the variable echo $CURCOL Unfortunately, this prints characters to the standard output and I want to do it silently. Besides, this is not very portable... Is there a pure-bash way to achieve this ?

    Read the article

  • SimpleDateFormat give inconsistent results

    - by Julien Gagnet
    I am trying to parse a date and I am getting different results when I run the code locally/BST compare to a server in Paris/CEST. I've reproduced the issue in a the following sample. This is trying to parse the start date for the Australian Grand Prix. TimeZone tz = TimeZone.getTimeZone("AET"); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH mm"); dateFormat.setTimeZone(tz); long time = dateFormat.parse("28/03/2010 17 00").getTime(); System.out.println("Time "+time); It seems like I am setting the timezone correctly on the date format and the current timezone shouldn't be affecting the code. But locally it prints 1269756000000 and in Paris 1269759600000. Any idea?

    Read the article

  • PHP IF condition advise needed

    - by Jose David Garcia Llanos
    I'm using emails as username to login into a site being developed, now if a user updates their email from the profile page, how can i make sure that my email checking statement doesnt catch the user's email as already registered in the database. the page /* Now we will store the values submitted by form in variable */ $fullname=$_POST['fullname']; $dob=$_POST['dob']; $address=$_POST['address']; $myusername=$_POST['myusername']; $telephone=$_POST['telephone']; $queryuser=mysql_query("SELECT * FROM customer WHERE email='$myusername' "); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { $Merr[]='&raquo; Sorry this email is already registered!'; } else {$insert_user=mysql_query("UPDATE CUSTOMER SET SYNTAX HERE"); Now these are the fields in question; (name, dob, address, email, telephone) VALUES ('$fullname', '$dob', '$address', '$myusername', '$telephone') As you can see if the user changes the login email then the syntax checks for the email being submitted against the database, however if the user leaves the email unchanged he will get the error because it is found in the database. I was thinking of something like; if($checkuser != 0) { if($myusername == $_POST['myusername']) (...dont show error.) but my php skills are limited. can anyone advise please, thanks

    Read the article

  • Default value for hidden field in Django model

    - by Daniel Garcia
    I have this Model: class Occurrence(models.Model): id = models.AutoField(primary_key=True, null=True) reference = models.IntegerField(null=True, editable=False) def save(self): self.collection = self.id super(Occurrence, self).save() I want for the reference field to be hidden and at the same time have the same value as id. This code works if the editable=True but if i want to hide it it doesnt change the value of reference. how can i fix that?

    Read the article

  • How can I pass extra parameters to the routeMatch object?

    - by Marcos Garcia
    I'm trying to unit test a controller, but can't figure out how to pass some extra parameters to the routeMatch object. I followed the posts from tomoram at http://devblog.x2k.co.uk/unit-testing-a-zend-framework-2-controller/ and http://devblog.x2k.co.uk/getting-the-servicemanager-into-the-test-environment-and-dependency-injection/, but when I try to dispatch a request to /album/edit/1, for instance, it throws the following exception: Zend\Mvc\Exception\DomainException: Url plugin requires that controller event compose a router; none found Here is my PHPUnit Bootstrap: class Bootstrap { static $serviceManager; static $di; static public function go() { include 'init_autoloader.php'; $config = include 'config/application.config.php'; // append some testing configuration $config['module_listener_options']['config_static_paths'] = array(getcwd() . '/config/test.config.php'); // append some module-specific testing configuration if (file_exists(__DIR__ . '/config/test.config.php')) { $moduleConfig = include __DIR__ . '/config/test.config.php'; array_unshift($config['module_listener_options']['config_static_paths'], $moduleConfig); } $serviceManager = Application::init($config)->getServiceManager(); self::$serviceManager = $serviceManager; // Setup Di $di = new Di(); $di->instanceManager()->addTypePreference('Zend\ServiceManager\ServiceLocatorInterface', 'Zend\ServiceManager\ServiceManager'); $di->instanceManager()->addTypePreference('Zend\EventManager\EventManagerInterface', 'Zend\EventManager\EventManager'); $di->instanceManager()->addTypePreference('Zend\EventManager\SharedEventManagerInterface', 'Zend\EventManager\SharedEventManager'); self::$di = $di; } static public function getServiceManager() { return self::$serviceManager; } static public function getDi() { return self::$di; } } Bootstrap::go(); Basically, we are creating a Zend\Mvc\Application environment. My PHPUnit_Framework_TestCase is enclosed in a custom class, which goes like this: abstract class ControllerTestCase extends TestCase { /** * The ActionController we are testing * * @var Zend\Mvc\Controller\AbstractActionController */ protected $controller; /** * A request object * * @var Zend\Http\Request */ protected $request; /** * A response object * * @var Zend\Http\Response */ protected $response; /** * The matched route for the controller * * @var Zend\Mvc\Router\RouteMatch */ protected $routeMatch; /** * An MVC event to be assigned to the controller * * @var Zend\Mvc\MvcEvent */ protected $event; /** * The Controller fully qualified domain name, so each ControllerTestCase can create an instance * of the tested controller * * @var string */ protected $controllerFQDN; /** * The route to the controller, as defined in the configuration files * * @var string */ protected $controllerRoute; public function setup() { parent::setup(); $di = \Bootstrap::getDi(); // Create a Controller and set some properties $this->controller = $di->newInstance($this->controllerFQDN); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => $this->controllerRoute)); $this->event = new MvcEvent(); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator(\Bootstrap::getServiceManager()); } public function tearDown() { parent::tearDown(); unset($this->controller); unset($this->request); unset($this->routeMatch); unset($this->event); } } And we create a Controller instance and a Request with a RouteMatch. The code for the test: public function testEditActionWithGetRequest() { // Dispatch the edit action $this->routeMatch->setParam('action', 'edit'); $this->routeMatch->setParam('id', $album->id); $result = $this->controller->dispatch($this->request, $this->response); // rest of the code isn't executed } I'm not sure what I'm missing here. Can it be any configuration for the testing bootstrap? Or should I pass the parameters in some other way? Or am I forgetting to instantiate something?

    Read the article

  • Django make model field name a link

    - by Daniel Garcia
    what Im looking to do is to have a link on the name of a field of a model. So when im filling the form using the admin interface i can access some information. I know this doesn't work but shows what i want to do class A(models.Model): item_type = models.CharField(max_length=100, choices=ITEMTYPE_CHOICES, verbose_name="<a href='http://www.quackit.com/html/codes'>Item Type</a>") Other option would be to put a description next to the field. Im not even sure where to start from.

    Read the article

  • What should i do to test EasyMock objects when using Generics ? EasyMock

    - by Arthur Ronald F D Garcia
    See code just bellow Our generic interface public interface Repository<INSTANCE_CLASS, INSTANCE_ID_CLASS> { void add(INSTANCE_CLASS instance); INSTANCE_CLASS getById(INSTANCE_ID_CLASS id); } And a single class public class Order { private Integer id; private Integer orderNumber; // getter's and setter's public void equals(Object o) { if(o == null) return false; if(!(o instanceof Order)) return false; // business key if(getOrderNumber() == null) return false; final Order other = (Order) o; if(!(getOrderNumber().equals(other.getOrderNumber()))) return false; return true; } // hashcode } And when i do the following test private Repository<Order, Integer> repository; @Before public void setUp { repository = EasyMock.createMock(Repository.class); Order order = new Order(); order.setOrderNumber(new Integer(1)); repository.add(order); EasyMock.expectLasCall().once(); EasyMock.replay(repository); } @Test public void addOrder() { Order order = new Order(); order.setOrderNumber(new Integer(1)); repository.add(order); EasyMock.verify(repository) } I get Unexpected method call add(br.com.smac.model.domain.Order@ac66b62): add(br.com.smac.model.domain.Order@ac66b62): expected: 1, actual: 0 Why does it not work as expected ??? What should i do to pass the test ???

    Read the article

  • Serialize XML child and keep namespaces in Java

    - by Guido García
    I have an Document object that is modeling a XML like this one: <RootNode xmlns="http://a.com/a" xmlns:b="http://b.com/b"> <Child /> </RootNode> Using Java DOM, I need to get the <Child> node and serialize it to XML, but keeping the root node namespaces. This is what I currently have, but it does not serialize the namespaces: public static void main(String[] args) throws Exception { String xml = "<RootNode xmlns='http://a.com/a' xmlns:b='http://b.com/b'><Child /></RootNode>"; DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes())); Node childNode = doc.getFirstChild().getFirstChild(); // serialize to string StringWriter sw = new StringWriter(); DOMSource domSource = new DOMSource(childNode); StreamResult streamResult = new StreamResult(sw); TransformerFactory tf = TransformerFactory.newInstance(); Transformer serializer = tf.newTransformer(); serializer.transform(domSource, streamResult); String serializedXML = sw.toString(); System.out.println(serializedXML); } Current output: <?xml version="1.0" encoding="UTF-8"?> <Child/> Expected output: <?xml version="1.0" encoding="UTF-8"?> <Child xmlns='http://a.com/a' xmlns:b='http://b.com/b' />

    Read the article

  • Add columns to SqlWebEventProvider

    - by Julien N
    In an asp.net application, we'd like to use the SqlWebEventProvider to log any Event that occurs during the application lifetime. The problem is that we think that the table aspnet_WebEvent_Event doesn't provide enough columns and should log more information (we need to keep the Logged user). I'm aware that this information could be stored in the "Details" column but it wouldn't then be really simple to filter the results and build reports. So I'm searching for a simple solution to add a column. I wish I could derive SqlWebEventProvider but the methods used to build the stocked procedure parameters are private (PrepareParams() and FillParams()). Any simple solution that doesn't imply to rewrite the entire Provider class ?

    Read the article

  • Propietary modules within GPL and BSD kernels

    - by Francisco Garcia
    Since the Linux kernel is GPL and not LGPL I suppose that it is illegal to link proprietary code to it. How does the industry circumvents this? I would expect that the GPL license will force any developer to release under GPL driver and/or kernel module. Maybe I am confused and implementing a new module is not really linking against the kernel code ??? How do companies deal with this? Maybe linking the other way around (from kernel to their binaries)? On the other hand there is the BSD kernel. Where you are free to link protected IP. Can you get a better design implementing your drivers within a BSD kernel? Is there any design restriction when implementing drivers for GPL kernels?

    Read the article

  • ruby on rails params injection

    - by Julien P.
    Hello everyone, I have a question about ruby on rails and the process of assigning variables using the params variable passed through a form class User attr_accessible :available_to_admins, :name end Let's say that I have a field that is only available to my admins. Assuming that you are not an admin, I am going to not display the available_to_admins input in your form. After that, when I want to save your data I'll just do a: User.update_attributes(params[:user]) If you are an admin, then no problem, the params[:user] is going to contain name and available_tu_admins and if you're not then only your name. Since the available_to_admins is an attr_accessible parameter, how should I prevent non admin users from being able to inject a variable containing the available_to_admins input with their new value?

    Read the article

  • How to trace the connection pool in a Java Web application - DBMS_APPLICATION_INFO

    - by Cleiton Garcia
    Hello, I need improve the traceability in a Web Application that usually run on fixed db user. The DBA should have a fast access for the information about the heavy users that are degrading the database. 5 years ago, I implemented a .NET ORM engine which makes a log of user and the server using the DBMS_APPLICATION_INFO package. Using a wrapper above the connection manager with the following code: DBMS_APPLICATION_INFO.SET_MODULE('" + User + " - " + appServerMachine + "',''); Each time that a connection get a connection from the pool, the package is executed to log the information in the V$SESSION. Has anyone discover or implemented a solution for this problem using the Toplink or Hibernate? Is there a default implementation for this problem? I found here a solutions as I implemented 5 years ago, but I'd like to know with anyone have a better solution and integrated with the ORM. http://stackoverflow.com/questions/53379/using-dbmsapplicationinfo-with-jboss My application is above Spring, the DAO are implemented with JPA (using hibernate) and actually running directly in Tomcat, with plans to (next year) migrate to SAP Netwevare Application Server. Thanks.

    Read the article

  • Distributed datastore

    - by Julien Genestoux
    We're trying to add some kind of persistence in our app. The app generates about 250 entries per second. Each of these entries belong to one of 2M files. For each file, we want to keep the last 10 entries, so we can look them up later. The way our client application works : it gets a stream of all the data it fetches the right file (GET) it adds the new content it saves the file back (PUT) We're looking for an efficient way to store this data that can scale horizontally as the amount of data we're getting is doubling every few weeks. We initially looked at S3. It works fine, but becomes very expensive very fast ($1000 monthly just in PUT operations!) We then gave a shot at Riak. But it seems we can't get more than 60 write/sec on each node, which is very very slow. Any other solution out there?

    Read the article

  • Tomcat Compression Does Not Add a Content-Encoding: gzip in the Header

    - by Julien Chastang
    I am using Tomcat to compress my HTML content like this: <Connector port="8080" maxHttpHeaderSize="8192" maxProcessors="150" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="150" connectionTimeout="20000" disableUploadTimeout="true" compression="on" compressionMinSize="128" noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html" URIEncoding="UTF-8" /> In the HTTP header (as observed via YSlow), however, I am not seeing Content-Encoding: gzip resulting in a poor YSlow score. All I see is HeadersPost Response Headers Server: Apache-Coyote/1.1 Content-Type: text/html;charset=ISO-8859-1 Content-Language: en-US Content-Length: 5251 Date: Sat, 14 Feb 2009 23:33:51 GMT I am running an apache mod_jk Tomcat configuration. How do I compress HTML content with Tomcat, and also have it add "Content-Encoding: gzip" in the header?

    Read the article

  • How do you handle browser cache with login/logout?

    - by Julien
    To improve performances, I'd like to add a fairly long Cache-Control (up to 30 minutes) to each page since they do not change often. However, each page also displays the name of the user logged in (like this website). The problem is when the user logs in or logs out: the user name must change. How can I change the user name after each login/logout action while keeping a long Cache-Control? Here are the solutions I can think of: Ajax request (not cached) to retrieve and display the user name. If I have 2 requests (/user?registered and /user?new), they could be cached as well. But I am afraid this extra request would nullify my caching performance-wise Add a unique URL variable (?time=) to make the URL different, and cancel the cache. However, I would have to add this variable to all links on my webpage, not very convenient code-wise This problems becomes greater if I actually have more content that is not the same for registered users and new users.

    Read the article

  • JPA : Inheritance - Discriminator value not taken into account in generated SQL

    - by Julien
    I try to use this mapping : @Entity @Table(name="ecc.\"RATE\"") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="DISCRIMINATOR", discriminatorType= DiscriminatorType.STRING) public abstract class Rate extends GenericBusinessObject { ... } @Entity @DiscriminatorValue("E") public class EntranceRate extends Rate { @ManyToOne @JoinColumn(name = "\"RATES_GRID_ID\"") protected RatesGrid ratesGrid; ... } @Entity @Table(name="ecc.\"RATES_GRID\"") public class RatesGrid extends GenericBusinessObject { /** */ @OneToMany(mappedBy = "ratesGrid", targetEntity = EntranceRate.class, fetch=FetchType.LAZY) private List<EntranceRate> entranceRates; } When I try to access my entranceRates list from a ratesGrid object, I get this error : Object with id: 151 was not of the specified subclass: com.ecc.bo.rate.EntranceRate (loaded object was of wrong class class com.ecc.bo.rate.AnnualRate) Looking at the sql generated, I found no trace of "discriminator=" in the where clause. What am I doing wrong ? I use a PostGreSQL database and a Hibernate as JPA provider.

    Read the article

  • Symfony - Several form on the same page -> ID issue

    - by Julien
    Hi folks. I have an issue while displaying several forms of the same model on the same page. The problem is that with the NameFormat, the fields have the same ID : $this->widgetSchema->setNameFormat('display[%s]'); Will display <form class="update_display_form" id="update_display_0" action="/iperf/web/frontend_dev.php/update_display" method="post"> <input type="checkbox" name="display[displayed]" checked="checked" id="display_displayed" /> <label for="display_displayed">test</label> </form> <form class="update_display_form" id="update_display_1" action="/iperf/web/frontend_dev.php/update_display" method="post"> <input type="checkbox" name="display[displayed]" checked="checked" id="display_displayed" /> <label for="display_displayed">truc</label> </form> And if you click on the second label, it will activate the first checkbox So I thought I could use the object id to make them unique : $this->widgetSchema->setNameFormat('display'.$this->getObject()->getId().'[%s]'); But then I can not process the request, since I don't know the name of the parameters. The best option I found was to set an ID : $this->widgetSchema['displayed']->setAttributes(array("id" => "display".$this->getObject()->getId() )); but then I totally loose the connections between the label and the checkbox. The problem would be solved if I could change the "for" attribute of my label. Does somebody know how to do that ? Or any other option ?

    Read the article

  • Get Max() record from table by group

    - by Garcia Julien
    Hi, i've got a table like that : Article Number Last Voucher Number Last Voucher Date 0557934 519048 04/02/2005 0557934 519067 04/02/2005 0557934 528630 09/29/2005 0557934 528631 09/29/2005 0557934 529374 10/13/2005 0557934 529375 10/13/2005 0557934 529471 10/16/2005 0557934 529472 10/16/2005 0557934 535306 01/08/2006 0557934 535307 01/08/2006 0557934 1106009 08/10/2006 0557934 1106010 08/10/2006 0022738 22554 02/20/1995 0022738 22595 03/12/1995 0022738 22597 03/15/1995 0022738 22605 03/19/1995 0022738 22616 03/25/1995 0022738 22621 03/28/1995 0022738 22630 04/05/1995 I would like to have only the record with the last date : Article Number Last Voucher Number Last Voucher Date 0557934 1106010 08/10/2006 0022738 22630 04/05/1995 I can do directly on SQL or on Linq. Any idea? Ju

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11  | Next Page >